Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

447
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda