AESENCODER

Everything else that doesn't fall into one of the other PB categories.
marsu
New User
New User
Posts: 3
Joined: Wed Aug 06, 2008 10:49 am
Location: FRANCE

AESENCODER

Post by marsu »

Bonjour à tous, je cherche à passer en unicode, et je ne comprend pas pourquoi dans ce code le résultat de l'encodage diffère lorsque l'on est en unicode ou en ascci alors que l'entrée est la même.

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

User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: AESENCODER

Post by Kwai chang caine »

Bonjour Marsu
Ton message n'est ni dans la bonne rubrique, ni dans la bonne langue
Ici c'est un forum anglais, si tu veux être aidé au mieux, sache que toutes les nationalités cohabitent, alors si chacun parlait dans sa langue, j'te parle pas du bordel :wink:
Donc on ne parle qu'en anglais, ou au pire dans certaines circonstances en anglais traduit GOOGLE, si tu ne sais pas le parler, et en second plan le même texte en français si tu veux exprimer quelque chose de précis pour FRED que tu penses ne pas pouvoir lui dire en anglais

ensuite lorsque l'on pose une question de ce type c'est dans la section DEBUTANT sur le forum FRANCAIS et "Coding Questions" sur celui ci..à croire que quand on parle anglais, il n'y a pas de débutants :shock: :lol:

Pour tes questions en Français il y a ce forum :wink:
http://www.purebasic.fr/french/

Bienvenue dans la communauté 8)

My message can be removed by a moderator :wink:
ImageThe happiness is a road...
Not a destination
Post Reply