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

339
Visualizações
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 Respostas
Responde à pergunta

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 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