Forum,
I need to define a 128 bit string to use as a Key for encrypt().
I've defined a Hex string to represent the 128 bits = "C0FB7F4F840BBDC0F3FF1A2E0BA9E179"
The problem is that the string is not interpreted as HEX, but as 8 bit Ascii characters, which is 256 bits.
How do you represent a Hex String in LiveCode. I tried to prefix it with "0x", but that is rejected as to long.
I've tried format(), binaryEncode(), binaryDecode(), but I'm not doing something correctly.
If it cut the string in half, to 16 characters, encrypt works just fine, but that is not the Key that I need to use.
This seems very simple, but I cannot find it documented anywhere, but then I'm probably looking in the wrong place.
Thanks for the help.
Hex String Definition
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: Hex String Definition
Does
give you what you want?
Code: Select all
put binaryEncode("H*", "C0FB7F4F840BBDC0F3FF1A2E0BA9E179")
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
-
- Posts: 87
- Joined: Tue Nov 13, 2007 6:40 pm
Re: Hex String Definition
Thanks
The binaryEncode gives the binary string and the encrypt function didn't complain.
I was thinking that I could put a indication at the start of the string to indicate that it was a Hex value without the conversion.
Thanks for the fast response. I will see how that works.
dcpbarrington
The binaryEncode gives the binary string and the encrypt function didn't complain.
I was thinking that I could put a indication at the start of the string to indicate that it was a Hex value without the conversion.
Thanks for the fast response. I will see how that works.
dcpbarrington
Re: Hex String Definition
You could, but I think with that many bits you might overflow the math library.I was thinking that I could put a indication at the start of the string to indicate that it was a Hex value without the conversion.
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
-
- Posts: 87
- Joined: Tue Nov 13, 2007 6:40 pm
Re: Hex String Definition
Thanks for the reply
On the binaryEncode() function there are two HEX options.
h: encode amount groups of 2 characters as hexadecimal numbers
H: encode amount groups of 2 characters as hexadecimal, starting at the high end of each byte
Using the "H" value is the correct selection as you noted. Just to be sure I then verified that the bit stream was generated correctly by doing a get binaryDecode( "B*", tKeyHex, tKeyBinary)
Thanks for the help.
dcpbarrington
On the binaryEncode() function there are two HEX options.
h: encode amount groups of 2 characters as hexadecimal numbers
H: encode amount groups of 2 characters as hexadecimal, starting at the high end of each byte
Using the "H" value is the correct selection as you noted. Just to be sure I then verified that the bit stream was generated correctly by doing a get binaryDecode( "B*", tKeyHex, tKeyBinary)
Thanks for the help.
dcpbarrington