AES encryption in python and decrypting in ReactJs

433 Views Asked by At

I have Encrypted a string in python using pycryptodome lib and I want to decrypt the string in react using cryptoJs, but I could not find any proper way to do that.

this is my code in python:

def encrypt_string(string):
   aes = AES.new(secret_key, AES.MODE_CFB, secret_iv)
    encrypted = aes.encrypt(string.encode('utf-8'))
    return b64encode(encrypted).decode('utf-8')

js:

let decrypted = crypto.AES.decrypt(crypto.enc.Base64.parse(encrypted_string), key, { mode: crypto.mode.CFB, iv })
console.log(decrypted.toString(crypto.enc.Utf8)) //returns empty string

this implementation returns an empty string.

0

There are 0 best solutions below