I faced the same problem until I figured out how to handle it...
I use these two subs, built up from the example, to encrypt strings for a registry, and then decrypt back.
Sub EncryptIt(a)
string() = Bit.StringToBytes(a,0,StrLength(a)) 'Convert the string to an array of bytes.
secret() = Crypto.Encrypt(ED, string()) 'Save the encrypted data.
for i = 0 to ArrayLen(secret())-1 'Show the encrypted data in the TextBox
ss = bit.DecToHex(secret(i))
If StrLength(ss)<2 then ss = "0" & ss ' Add leading zero to byte if not two digits!
s = s & ss
next
Return s
End Sub
Sub DecryptIt(aa)
y = StrLength(aa) / 2
Dim NewArray(y) as Byte ' Array may end up being 8, 16, 32... bytes long
For z = 0 to (StrLength(aa) / 2) - 1 ' Hex values are two digits long (8 byte should be 0 to 3 loop)
NewArray(z)= bit.HexToDec(StrAt(aa,z * 2) & StrAt(aa,(z * 2)+1))
Next
if ArrayLen(NewArray()) = 0 then return
string() = Crypto.Decrypt(ED,NewArray()) 'Decrypt the data.
zz = Bit.BytesToString(string(),0,ArrayLen(string())) 'Convert the array to a string.
Return zz
End Sub
Regards,
Mike