Versuche gerade, das Beispiel in der Hilfe für meine Zwecke umzubauen, krieg's aber nicht hin. Da wird zwar was encodiert, aber das Decoden will nicht. Kann mir da mal jemand über die Schulter gucken?
Code: Alles auswählen
Procedure.s Encode(pstr$)
StringMemorySize = StringByteLength(pstr$) + SizeOf(Character)
*CipheredString = AllocateMemory(StringMemorySize)
*DecipheredString = AllocateMemory(StringMemorySize)
If AESEncoder(@pstr$, *CipheredString, StringByteLength(pstr$), ?Key, 128, ?InitializationVector)
Return$ = PeekS(*CipheredString)
Else
Return$ = ""
EndIf
FreeMemory(*CipheredString)
FreeMemory(*DecipheredString)
ProcedureReturn Return$
EndProcedure
Procedure.s Decode(pstr$)
StringMemorySize = StringByteLength(pstr$) + SizeOf(Character)
*CipheredString = AllocateMemory(StringMemorySize)
*DecipheredString = AllocateMemory(StringMemorySize)
If AESDecoder(*CipheredString, *DecipheredString, StringByteLength(pstr$), ?Key, 128, ?InitializationVector)
;Debug "Deciphered: "+PeekS(*DecipheredString)
Return$ = PeekS(*DecipheredString)
Else
Return$ = ""
EndIf
FreeMemory(*CipheredString)
FreeMemory(*DecipheredString)
ProcedureReturn Return$
EndProcedure
DataSection
Key:
Data.b $06, $a9, $21, $40, $36, $b8, $a1, $5b, $51, $2e, $03, $d5, $34, $12, $00, $06
InitializationVector:
Data.b $3d, $af, $ba, $42, $9d, $9e, $b4, $30, $b4, $22, $da, $80, $2c, $9f, $ac, $41
EndDataSection
pw$ = "1234567890abcABC"
x$ = Encode(pw$)
Debug x$
Debug Decode(x$)