Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

443
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!