lundi 29 juin 2015

Decrypt a file encrypted using openssl in as3?

I have a file encrypted using openssl that I need to decrypt in flash. The encrypted file was generated using this command in openssl:

openssl aes-256-cbc -in "file-to-be-encrypted.jpg" -out "encrypted-a.txt" -a

and in AS3, I use as3crypto with the following code:

var file:File = File.desktopDirectory.resolvePath("encrypted-a.txt");
var fileStream:FileStream = new FileStream();, FileMode.READ);
var ba:ByteArray = new ByteArray();
var key:ByteArray = Hex.toArray("password");
var aes:AESKey = new AESKey(key);
var decryptedBytes:ByteArray =  Hex.toArray(Base64.decode(ba.readUTFBytes(ba.bytesAvailable)));
try {
    aes.decrypt( decryptedBytes );

var decryptedFile:File = File.desktopDirectory.resolvePath("decrypted-a.png");
var decryptedFileStream:FileStream = new FileStream();, FileMode.WRITE);

Unfortunately the decrypted file in as3 is not identical to the original file. Anybody have any ideas?

Aucun commentaire:

Enregistrer un commentaire