When you want to realize encryption with the'-nosalt'option in Python with the following AES-256 CBC encryption with openssl.
echo "this is secret"|openssl enc -aes-256-cbc -e -base64 -pass pass:hogehoge -p -nosalt
It was made like this.
def encryptAes(str, encKey, key_length=32, iv_length=16):
    d = d_i = ''
    while len(d) < key_length + iv_length:
        d_i = md5(d_i + encKey).digest()
        d += d_i
    key = d[:key_length]
    iv = d[key_length:key_length+iv_length]
    cipher = AES.new(key, AES.MODE_CBC, iv)
    _str = str + (iv_length - len(str) % iv_length) * chr(iv_length - len(str) % iv_length)
    return base64.b16encode(cipher.encrypt(_str)).lower()
print encyptAes("this is secret","hogehoge")
Leave as a memorandum.
Recommended Posts