Le but est de décoder un buffer qui a était encoder en ascii puis encoder en base 64.
Le décodage en base 64 me renvoie bien le même résultat en unicode ou as ascii, mais lorsque je met ce résultat en entrée de aesdecoder, le resultat est correcte en ascii mais pas en unicode.
Du coup je fais le test avec le code suivant est en effet l'encodage diffère. Est-ce que quelqu'un pourrait m'expliquer ?
Code: Select all
Define keyn.s, InitVectorN.s, str.s,tmp.s
Define NbBits.l, Taille.l,i.l
Define *InitVectorN, *KeyN,*encoded,*decoded,*DecipheredString
KeyN="06A9214036B8A15B512e03d534120006"
InitVectorN="3DAFBA429D9EB430B422DA802C9FAC41"
tmp=""
For i = 1 To Len (Keyn) Step 2
tmp+Chr(Val("$"+Mid(keyn, i,2)))
Next
keyn=tmp
tmp=""
For i = 1 To Len (InitVectorN) Step 2
tmp+Chr(Val("$"+Mid(InitVectorN, i,2)))
Next
InitVectorN=tmp
*InitVectorN=AllocateMemory(StringByteLength(InitVectorN ))
PokeS(*InitVectorN, InitVectorN, -1, #PB_Ascii|#PB_String_NoZero )
*InitVectorN=ReAllocateMemory(*InitVectorN, Len(InitVectorN))
*KeyN=AllocateMemory(StringByteLength(keyn))
PokeS(*KeyN, keyn, -1, #PB_Ascii|#PB_String_NoZero )
*KeyN=ReAllocateMemory(*KeyN, Len(keyn))
Define String.s = "Test encodage AES"
Define *DecipheredString = AllocateMemory(StringByteLength(String))
PokeS(*DecipheredString, String, -1, #PB_Ascii)
*DecipheredString=ReAllocateMemory(*DecipheredString, Len(string)+1)
Define *CipheredString = AllocateMemory(MemorySize(*DecipheredString) )
ShowMemoryViewer(*DecipheredString, MemorySize(*DecipheredString))
If AESEncoder(*DecipheredString, *CipheredString, Len(string), *KeyN, 128, *InitVectorN)
; Why *CipheredString is not the same when i compile in unicode and in ascii ?
ShowMemoryViewer(*CipheredString, MemorySize(*CipheredString))
AESDecoder(*CipheredString, *DecipheredString, Len(String), *keyn, 128, *InitVectorN)
ShowMemoryViewer(*DecipheredString, MemorySize(*DecipheredString))
Debug "Deciphered: " + PeekS(*DecipheredString, -1, #PB_Ascii)
EndIf