Decrypting AES-128-ECB string with no salt
Posted: Thu Jul 10, 2014 5:35 am
Hello,
I've just started using LiveCode community edition and am trying to use the encrypt/decrypt commands to store and retrieve passwords locally for a legacy application on another platform.
The scenario is that I have a 32 character alphanumeric string representing the password stored in a text field -
ec16882f9fd3a59077fae786fc46a233, which is 'password' encrypted with 'secret' using AES-128-ECB.
My understanding is that I would use the decrypt command to convert this to plaintext.
I have two fields (tHexValue and tClearText) in the stack and a button with code in the onmouseup event:
decrypt field tHexValue using "aes128" with password "secret"
put it into tClearText
This fails and there's no obvious error.
To troubleshoot, I tried encrypting using the equivalent, but got a string I wasn't expecting.
encrypt field tClearText using "aes128" with password "secret"
put it into tHexValue
Result:
Salted__U¹)T[³%ÁFd"ºo¡©j/µ
My question is how do I convert the output into a 32 character alphanumeric string 'ec16882f9fd3a59077fae786fc46a233'?
I'm also not sure how to handle the lack of a salt value, as the documentation seems to indicate a random salt is used if one isn't specified in the command?
I'm probably missing something really obvious, but would appreciate any pointers or assistance.
Thank you.
Calvin.
I've just started using LiveCode community edition and am trying to use the encrypt/decrypt commands to store and retrieve passwords locally for a legacy application on another platform.
The scenario is that I have a 32 character alphanumeric string representing the password stored in a text field -
ec16882f9fd3a59077fae786fc46a233, which is 'password' encrypted with 'secret' using AES-128-ECB.
My understanding is that I would use the decrypt command to convert this to plaintext.
I have two fields (tHexValue and tClearText) in the stack and a button with code in the onmouseup event:
decrypt field tHexValue using "aes128" with password "secret"
put it into tClearText
This fails and there's no obvious error.
To troubleshoot, I tried encrypting using the equivalent, but got a string I wasn't expecting.
encrypt field tClearText using "aes128" with password "secret"
put it into tHexValue
Result:
Salted__U¹)T[³%ÁFd"ºo¡©j/µ
My question is how do I convert the output into a 32 character alphanumeric string 'ec16882f9fd3a59077fae786fc46a233'?
I'm also not sure how to handle the lack of a salt value, as the documentation seems to indicate a random salt is used if one isn't specified in the command?
I'm probably missing something really obvious, but would appreciate any pointers or assistance.
Thank you.
Calvin.