In my cace, a chinese string is produced, what am I missing? Is this normal?
Code: Select all
InitNetwork()
key.s = "12345678901234567890123456789012"
InitializationVector.s = "09876543210987654321098765432100"
String$ = "string coming from the client..."
StringMemorySize = StringByteLength(String$) + SizeOf(Character) ; Space for the string and its null terminating character
*CipheredString = AllocateMemory(StringMemorySize)
*DecipheredString = AllocateMemory(StringMemorySize)
outsize.i = StringMemorySize*3; for Base64
*str = AllocateMemory(outsize); for Base64
If AESEncoder(@String$, *CipheredString, StringByteLength(String$), @Key, 256, @InitializationVector)
Debug "Ciphered: "+PeekS(*CipheredString)
Debug "base64 = " + Base64EncoderBuffer(*CipheredString, StringByteLength(String$) + SizeOf(Character),*str,outsize)
Debug "str = " + PeekS(*str,#PB_UTF8)
Debug "str = " + PeekS(*str,#PB_Unicode)
Debug "str = " + PeekS(*str,#PB_Ascii)
Decoded$ = Space(1024)
Debug Base64DecoderBuffer(*str,outsize,@Decoded$, StringByteLength(Decoded$))
Debug "decoded = " + Decoded$
AESDecoder(@Decoded$, *DecipheredString, StringByteLength(String$), @Key, 256, @InitializationVector)
Debug "Deciphered: "+PeekS(*DecipheredString)
EndIf
Debug "ok"