This is a kind of pain associated with openssl, because openssl encryption makes assumptions about filling in and derives the salt key from the entered password, which you should intentionally disable.
This is much easier to do in python using PyCrypto , where these assumptions are not fulfilled.
>>> import base64 >>> data = base64.b64decode('y2EdLtmNQsZkvwwf8jf3fM6c1thfzF0sQfblayGIBik=') >>> from Crypto.Cipher import AES >>> aes_crypter = AES.new('h4ckth1sk3yp4d16', AES.MODE_CBC, data[:16]) >>> aes_crypter.decrypt(data[16:])
This can be done using openssl, but you have to read the data encoded in base64 - take out the first 16 bytes and remember it as your $IV
(after encoding it back to the hex that openssl expects), start by reading all the bytes after the first 16 and remember it as $CIPHERTEXT
(and say transcode to base64). Similarly for $KEY
, you must convert it from ASCII to bytes in hexadecimal format. Assuming you saved them in variables, the following will work:
IV=`base64 -d part444.txt | xxd -p -l 16` CIPHERTEXT=`base64 -d part444.txt | cut -b 17- | base64` KEY=`echo -n h4ckth1sk3yp4d16 |xxd -p` echo $CIPHERTEXT | openssl aes-128-cbc -d -a -nopad -K $KEY -iv $IV && echo ""
Note base64 -d
decodes base64 into a binary file (using base64 from GNU coreutils, when replacing BSD with base64 -d
), base64
b64 encodes binary data, cut -b 17-
reads from the 17th byte of data to the end of the file and xxd -p
converts binary to hexadecimal.
source share