30.07.2020, 06:20
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