2017-04-14 4 views
-1

Ich habe ein einfaches Konsolenprogramm, das Dateien mit AES CFB-Algorithmus von Crypto ++ Bibliothek verschlüsseln sollte. Aus irgendeinem Grund funktioniert es nicht. Encoding Teil:Verschlüsselung mit Crypto ++/AES CFB funktioniert nicht

byte data[16] = { 0x88, 0x44, 0x88, 0x44, 
        0x88, 0x44, 0x88, 0x44, 
        0x88, 0x44, 0x88, 0x44, 
        0x88, 0x44, 0x88, 0x44 }; 

byte result[16] = { 0x88, 0x44, 0x88, 0x44, 
        0x88, 0x44, 0x88, 0x44, 
        0x88, 0x44, 0x88, 0x44, 
        0x88, 0x44, 0x88, 0x44 }; 

//Sample key 
byte key[16] = { 0x88, 0x44, 0x88, 0x44, 
       0x88, 0x44, 0x88, 0x44, 
       0x88, 0x44, 0x88, 0x44, 
       0x88, 0x44, 0x88, 0x44 }; 

//Generate random Initialization Vector 
byte iv[16]; 
CryptoPP::AutoSeededRandomPool rnd; 
rnd.GenerateBlock(iv, CryptoPP::AES::BLOCKSIZE /*16*/); 

//Through VisualStudio debug/watch functionality I have found out that 
//Crypto++ randomizer works properly so at this point "iv" contains random values 

CryptoPP::CFB_Mode<CryptoPP::AES>::Encryption tmp(key, 16, iv, 1); 
tmp.ProcessData(data, result, 16); 

Das Problem ist, dass, wenn dieser Code result vervollständigt sollte mit Chiffriertext gefüllt werden, aber es bleibt nur gefüllt mit px88 und 0x44.

wurde ich von diesem offiziell Tutorial geführt: https://www.cryptopp.com/wiki/Advanced_Encryption_Standard

+0

Mögliches Duplikat von [AES-Verschlüsselung mit Crypto ++ funktioniert nicht] (http://stackoverflow.com/questions/43352882/aes-encryption-with-crypto-not-working) – jww

+0

Verzeihen Sie meine Ignoranz ... Wie ist das anders als das zitierte Duplikat? – jww

+0

@jww. Sie haben keinen Unterschied. Ich habe es getan, weil ich auf diese Frage keine Antwort hatte. – Serid

Antwort

3

ProcessData ist outstring, dann instring dann Länge. Sie haben die Eingabe- und Ausgabeparameter data & result gewechselt (die meisten APIs würden Ausgabeparameter zuletzt in ihren Methodendeklarationen angeben, so dass dies den Fehler erklären könnte).

+0

Vielen Dank! Das hat mein Problem gelöst! – Serid

Verwandte Themen