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

333
Vistas
TypeError: CryptoJS is undefined

Im working on a project in ReactJS and I want to implement the AES function from CyptoJS library. But when I perform the event that triggers the use of the AES ecrypting I recieve the following error: TypeError: crypto_js__WEBPACK_IMPORTED_MODULE_1__.CryptoJS is undefined

import React, {useState} from 'react';
import {CryptoJS} from 'crypto-js';
export function Register(){
    var body = /* a JSON with information from the register */
    var encyMssg = CryptoJS.AES.encrypt(JSON.stringify(body), "key").toString();

    return(/* HTML COMPONENT*/);
}

The error displays in the var encyMssg line and this script is written in a .jsx file. Any kind of solution? Thank you for your time.

SOLVED thanks a lot. The problem as several of you said was the {} in the import line; the correcto way to import the libray was:

import CryptoJS from 'crypto-js';
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Make sure you have to installed crypto-js using

npm install crypto-js


Then in your JS file import module you want to use.

import aes from 'crypto-js/aes';

Now you can aes like below.

aes(value, key).toString()


Here is working stackblitz example.

React Crypto AES StackBlitz

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