Encryption / Encoding Differences between IDE and OS X Standalone
Peter W A Wood
peterwawood at gmail.com
Thu Feb 20 01:57:41 EST 2014
Many thanks to Jan for the helpful suggestions with which I have improved the code.
Unfortunately, it didn't solve the problem. I have cut down the code so that the encryption uses only a plaintext password, no sha1 hashing, no salt and no initial value. Thanks to Jan's Base64 encoding suggestion, I can see clearly that I get different encrypted values when running in the IDE to running the stack as a standalone.
Here's the cutdown script:
local tData
local tDisplay
local tPassword
on openStack
put "12345678" into tPassword
end openStack
on encryptMSG
put Field "In" into tData
encrypt tData using "aes256" with password tPassword
put it into tDisplay
put the base64Encode of tDisplay into Field "Out"
end encryptMSG
on decryptMSG
put the base64Decode of Field "In" into tData
decrypt tData using "aes256" with password tPassword
put it into Field "Out"
end decryptMSG
When I encrypt Is this a bug? in the IDE the encrypted value is U2FsdGVkX1+phY3qAHj6kKxYtytOeLA7K/TM+9tfP+Y= but in the standalone it is U2FsdGVkX1/wFDjazwOsvXrEzPHQNcmvBa6nfU2rSJE=
I wonder if it is the standalone settings that I am using as in addition to this difference, as I also cannot copy the contents of Field "Out" to the clipboard using command-C in the standalone. (Though apart from selecting Intel only, I haven't changed any of the default settings).
Regards
Peter
http://LiveCode1001.blogspot.com
On 20 Feb 2014, at 13:45, Jan Schenkel wrote:
> Hi Peter,
>
> Fields are meant for the display of text, not binary data.
> You could 'base64encode' the binary data before you display it.
>
> Oh, and when treating binary data, you should the 'byte' chunk instead of the 'char' chunk.
> That way when LiveCode goes all-in Unicode, your script will continuye to work.
>
> HTH,
>
> Jan Schenkel
>
> =====
> Quartam Reports & PDF Library for LiveCode
> www.quartam.com
>
> =====
> "As we grow older, we grow both wiser and more foolish at the same time." (La Rochefoucauld)
>
More information about the use-livecode
mailing list