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

108
Vistas
Require CryptoJS Function Returning Wrong Thing

I am attempting to SHA3 a password. It works, and I make the hash.

var hash = CryptoJS.SHA3(pass, { outputLength: 512});
console.log(hash.toString());

and the result is:

8ca32d950873fd2b5b34a7d79c4a294b2fd805abe3261beb04fab61a3b4b75609afd6478aa8d34e03f262d68bb09a2ba9d655e228c96723b2854838a6e613b9d

which is what I want.

The issue is that this code is in this:

this.pass = require(["crypto-js"], function(CryptoJS) {
       console.log(pass);
       var hash = CryptoJS.SHA3(pass, { outputLength: 512});
       console.log(hash.toString());
       return hash.toString();     
});

Which doesn't actually set my variable to it. I instead get the function.

I've now sat here for probably 6-7 hrs trying random stuff.

I know it doesn't make sense the way I'm doing it, but I included require as a script tag in html. This is because I'm not actually running an npm server. This is also a browser extension. I am also aware my title makes it sound like "I'm right, code is wrong" trust me I know I'm wrong just please help me.

Tried various forms of setting this.pass. Tried to pass in this.pass. Tried setting this.pass inside the function. I don't know anymore.

about 4 years ago · Juan Pablo Isaza
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