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.

How to convert PHP pack function into Lua equivalent?
#1
Hello,

Does anyone know how I could convert the following PHP code to Lua?
Code:
MD5Salt = pack(
   "c*",
   0x86, 0x78, 0x45, 0xe9, 0x7c, 0x4e, 0x29, 0xdc,
   0xe5, 0x22, 0xb9, 0xa7, 0xd3, 0xa3, 0xe0, 0x7b,
   0x15, 0x2b, 0xff, 0xad, 0xdd, 0xbe, 0xd7, 0xf5,
   0xff, 0xd8, 0x42, 0xe9, 0x89, 0x5a, 0xd1, 0xe4
);

It looks like string.pack exists in Lua but I could not find it in LM.
I tried a few other approaches with some external libraries, but that failed, probably due to some incompatibilities.
I am a bit stuck here.
I need this to interface LM with a Buderus KM200, which uses an encrypted api.

Regards.
Michel.
Reply
#2
Use this:
Code:
MD5Salt = string.char(
    0x86, 0x78, 0x45, 0xe9, 0x7c, 0x4e, 0x29, 0xdc,
    0xe5, 0x22, 0xb9, 0xa7, 0xd3, 0xa3, 0xe0, 0x7b,
    0x15, 0x2b, 0xff, 0xad, 0xdd, 0xbe, 0xd7, 0xf5,
    0xff, 0xd8, 0x42, 0xe9, 0x89, 0x5a, 0xd1, 0xe4
)
Reply
#3
It works.
Thanks :-)
Reply


Forum Jump: