Logic Machine Forum
How to convert PHP pack function into Lua equivalent? - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: How to convert PHP pack function into Lua equivalent? (/showthread.php?tid=2043)



How to convert PHP pack function into Lua equivalent? - MichelDeLigne - 23.04.2019

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.


RE: How to convert PHP pack function into Lua equivalent? - admin - 23.04.2019

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
)



RE: How to convert PHP pack function into Lua equivalent? - MichelDeLigne - 24.04.2019

It works.
Thanks :-)