I need to decrypt an FTP password encrypted by pycrypto in AES CTR mode ,and for some reason I have to use cryptography instead,so how to do the decryption?
I want to know what is the nonce of cryptography should be?
this is the encrypt code by pycrypto
from Crypto.Util import Counter
from Crypto.Cipher import AES
def encrypt(text):
ctr = Counter.new(128, initial_value=1)
encrypto = AES.new(key, AES.MODE_CTR, counter=ctr)
encrypted = encrypto.encrypt(text)
return base64.b64encode(encrypted)
and the decrypt code by cryptography
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
def decrypt(text)
cipher = Cipher(algorithms.AES(key), None, backend=default_backend())
nonce = ?
cipher.mode = modes.CTR(nonce)
decryptor = cipher.decryptor()
decrypted = decryptor.update(encrypted.decode("base64"))
return decrypted