This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Buderus KM200 api
#12
(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
Reply


Messages In This Thread
Buderus KM200 api - by MichelDeLigne - 29.04.2019, 18:46
RE: Buderus KM200 api - by sds - 30.10.2019, 22:55
RE: Buderus KM200 api - by MichelDeLigne - 31.10.2019, 08:49
RE: Buderus KM200 api - by sds - 01.11.2019, 19:18
RE: Buderus KM200 api - by m.j.sorokin - 28.07.2020, 18:39
RE: Buderus KM200 api - by MichelDeLigne - 28.07.2020, 20:53
RE: Buderus KM200 api - by admin - 29.07.2020, 05:53
RE: Buderus KM200 api - by MichelDeLigne - 29.07.2020, 07:53
RE: Buderus KM200 api - by m.j.sorokin - 29.07.2020, 13:37
RE: Buderus KM200 api - by admin - 30.07.2020, 06:20
RE: Buderus KM200 api - by MichelDeLigne - 30.07.2020, 07:39
RE: Buderus KM200 api - by m.j.sorokin - 30.07.2020, 07:37
RE: Buderus KM200 api - by admin - 30.07.2020, 08:03
RE: Buderus KM200 api - by sds - 20.05.2024, 13:28
RE: Buderus KM200 api - by admin - 20.05.2024, 13:52
RE: Buderus KM200 api - by sds - 20.05.2024, 17:51
RE: Buderus KM200 api - by admin - 21.05.2024, 08:19
RE: Buderus KM200 api - by sds - 21.05.2024, 19:06

Forum Jump: