30.07.2020, 07:39
(30.07.2020, 06:20)admin Wrote: Replace km200_Decrypt function with this. Original function removes all data after the first "}" while it should remove it after the last "}", this is why you get an error when there are multiple "}" in returned data.
Code:function km200_Decrypt(decryptData)
local hash = { iv = string.rep('\0', 16) } -- no hashing method for key
local aes_256_ecb, err = aes:new(km200_crypt_key_private, nil, aes.cipher(256, 'ecb'), hash, nil, 0)
local res = aes_256_ecb:decrypt(encdec.base64dec(decryptData)) -- data block size is always 128 bits
-- Search the position of the last "}", and remove all the remaining padding after that
local endposition
while true do
local pos = res:find("}", endposition)
if pos then
endposition = pos + 1
else
break
end
end
if endposition then
res = res:sub(1, endposition - 1)
end
return res
end
Thanks admin for the correction.
Do you know why a find with a "-" does not work?
in Lua, if I am not mistaken, a find with a "-" in the argument would start the search from the end and find the first occurence of the character. That should find the last "}".
Obviously it does not work, so I am missing something here.
Regards.
Michel