Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

259
Visualizações
Trying to convert Javascript AES encryption to Python

I'm trying to convert the following Javascript code to python:

cryptoJs.AES.encrypt("secrettext", cryptoJs.enc.Base64.parse("QWJjZGVmZ2hpamtsbW5vcA=="), { iv: cryptoJs.enc.Base64.parse("AAAAAAAAAAAAAAAAAAAAAA==")}).ciphertext.toString(cryptoJs.enc.Base64)

I've been trying to figure out the python equivalent of the different parts (key and iv), but nothing is working. This is what I last tried but was given an error that my IV was the incorrect length:

key = b"QWJjZGVmZ2hpamtsbW5vcA=="
iv = b"AAAAAAAAAAAAAAAAAAAAAA=="
text = b"secrettext"

base64_key = base64.b64encode(key)
base64_iv = base64.b64encode(iv)

padtext=pad(text,16,style='pkcs7')

encryptor = AES.new(base64_key, AES.MODE_CBC, base64_iv)
result = encryptor.encrypt(padtext)
print(binascii.hexlify(result))
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda