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

452
Visualizações
What could cause this error: Uncaught TypeError: r.clamp is not a function?

I'm trying to use the following funciton to encrypt a Base64 encoded string using the AES-256-CFB algorithm, and when I try to encode the result back to Base64 it casues the following error: Uncaught TypeError: r.clamp is not a function

function (base64EncodedString, password) {
    let iv = CryptoJS.lib.WordArray.random(256 / 16);

    let salt = CryptoJS.enc.Hex.parse(iv.toString(CryptoJS.enc.Hex).substr(0, 16));

    let key = CryptoJS.EvpKDF(password, CryptoJS.enc.Hex.parse(salt), { keySize: 256 / 32 });

    let nonEncryptedString = CryptoJS.enc.Base64.parse(base64EncodedString);

    let cipher = CryptoJS.lib.CipherParams.create({ ciphertext: nonEncryptedString , iv: iv, salt: salt, mode: CryptoJS.mode.CFB, padding: CryptoJS.pad.NoPadding,});
    
    let encrypted = CryptoJS.AES.encrypt(cipher, key, {mode: CryptoJS.mode.CFB, padding: CryptoJS.pad.NoPadding, iv: iv});
        
    let ecrytpedBase64 = CryptoJS.enc.Base64.stringify(encrypted);
    
    return ecrytpedBase64;
};
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

This is happening because you're passing the encrypted variable (of type CipherParams) to the stringify function, which expects a WordArray (your iv variable).

CryptoJS.enc.Base64.stringify(encrypted); // TypeError: r.clamp is not a function
CryptoJS.enc.Base64.stringify(iv); // Ok
about 4 years ago · Juan Pablo Isaza Relatório
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