I've been looking for a python library to help decrypt an openssl blowfish encrypted password.
I have managed to achieve this in Java but the python libraries to support this appeared more of a learning curve, and required rolling your own.
In terms of what we need to achieve, the password is unsalted and uses a passphrase, for the purposes of this question I've set this to "AAAAAAAA". The Cipher is "Blowfish/CBC/PKCS5Padding". The encrypted text will be read in as a string, same as the key and iv.
In openssl, this is 'simply':
~$ # This is encrypting
~$ echo -n 'password' | openssl enc -bf -nosalt -a -K AAAAAAAA -iv AAAAAAAA
eAIUXziwB8QbBexkiIDR3A==
~$ # This is reversing the encryption
~$ echo 'eAIUXziwB8QbBexkiIDR3A==' | openssl enc -d -bf -nosalt -a -K AAAAAAAA -iv AAAAAAAA
password
In java, the descryption is along the lines of:
private static final String KEY = "AAAAAAAA000000000000000000000000";
private static final String IV = "AAAAAAAA00000000";
private static final String FCN = "Blowfish/CBC/PKCS5Padding";
private static final String CN = "Blowfish";
final byte[] encoded = Base64.decode("eAIUXziwB8QbBexkiIDR3A==");
final SecretKeySpec key =
new SecretKeySpec(Hex.decodeHex(KEY.toCharArray()), CN);
final Cipher cipher = Cipher.getInstance(FCN, JCE_PROVIDER);
cipher.init(Cipher.DECRYPT_MODE, key, new IvParameterSpec(Hex.decodeHex(IV.toCharArray())));
final byte[] decrypted = cipher.doFinal(encoded);
return new String(decrypted);
Can someone provide some guidance for python?