Code: Alles auswählen
DataSection
Key:
Data.b $06, $a9, $21, $40, $36, $b8, $a1, $5b, $51, $2e, $03, $d5, $34, $12, $00, $06, $a9, $21, $40, $36, $b8, $a1, $5b, $51, $2e, $03, $d5, $34, $12, $00, $06, $ff
InitializationVector:
Data.b $3d, $af, $ba, $42, $9d, $9e, $b4, $30, $b4, $22, $da, $80, $2c, $9f, $ac, $41
EndDataSection
Procedure.s EncryptString(StringtoEncrypt.s)
*CipheredString = AllocateMemory(Len(StringtoEncrypt)+1) ; Platz für den null-terminierten String
If AESEncoder(@StringtoEncrypt, *CipheredString, Len(StringtoEncrypt), ?Key, 256, ?InitializationVector)
Else
Debug "ERROR WHILE ENCRYPTING"
EndIf
Ausgabe.s = PeekS(*CipheredString)
FreeMemory(*CipheredString)
Ausgabe = Str(Len(StringtoEncrypt)) + "?" + Ausgabe
ProcedureReturn Ausgabe
EndProcedure
Procedure.s DecryptString(StringtoDecrypt.s)
Groesse = Val(Left(StringtoDecrypt,FindString(StringtoDecrypt,"?")))
StringtoDecrypt = Mid(StringtoDecrypt,FindString(StringtoDecrypt,"?") + 1)
Debug StringtoDecrypt
*DecipheredString = AllocateMemory(Groesse + 1) ; mit seiner abschließenden Null (ASCII-Modus)
If AESDecoder(@StringtoDecrypt, *DecipheredString, Groesse, ?Key, 256, ?InitializationVector)
Else
Debug "ERROR WHILE DECRYPTING"
EndIf
Ausgabe.s = PeekS(*DecipheredString)
FreeMemory(*DecipheredString)
ProcedureReturn Ausgabe
EndProcedure
Repeat
String.s = ""
For n = 0 To 16 + Random(400)
String.s = String.s + Chr(1 + Random(254))
Next
Encryptet.s = EncryptString(String)
Debug "Ciphered: " + Encryptet
Decrypted.s = DecryptString(Encryptet)
Debug "Deciphered: " + Decrypted
If Decrypted = String
Else
Debug "ERROR"
Delay(5000)
End
EndIf
ForEver