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

150
Visualizações
Inquiry About AES Encrypting Practice

I'm using NodeJS's crypto library and Crypto-JS. From the crypto library, I am generating ECDH client and generating the keys from which to use its private key for AES encryption with Crypto-JS in the future. the AES encryption function requires you to pass in a private key, which was done but it would not take it as a Buffer. It works when I use the hex string version, but I'm naïve and unsure if this has the strength of the ECDH private key I encoded to hex string.

Snippets of code to analyze (assume inData variable is a string):

var privBIN = programData.volatile.modularVariables.key; //some ECDH secret hex encoded
var inData = 'something';
var cipherInData = programData.volatile.modularVariables.cipherText(inData,privBIN);

key and value in programData object:

cipherText: (content, key)=>{console.log(`content: ${content}`); console.log(`key: ${key}`); return cryptojs.AES.encrypt(content,key).toString()},

The above ciphers the text in AES fine, but substitute priveBIN for:

var privBIN = Buffer.from(programData.volatile.modularVariables.key,programData.volatile.modularVariables.encoding.hex);

and suddenly it gives me the following error (I included where in crypto-js it has issues):

(node:15028) UnhandledPromiseRejectionWarning: TypeError: Cannot read property '0' of undefined
    at Object.xorBlock (C:\Users\Mickell\Desktop\CPHR\node_modules\crypto-js\cipher-core.js:371:44)
    at Object.processBlock (C:\Users\Mickell\Desktop\CPHR\node_modules\crypto-js\cipher-core.js:314:27)
    at Object._doProcessBlock (C:\Users\Mickell\Desktop\CPHR\node_modules\crypto-js\cipher-core.js:486:25)
    at Object._process (C:\Users\Mickell\Desktop\CPHR\node_modules\crypto-js\core.js:632:27)
    at Object._doFinalize (C:\Users\Mickell\Desktop\CPHR\node_modules\crypto-js\cipher-core.js:501:46)
    at Object.finalize (C:\Users\Mickell\Desktop\CPHR\node_modules\crypto-js\cipher-core.js:163:44)
    at Object.encrypt (C:\Users\Mickell\Desktop\CPHR\node_modules\crypto-js\cipher-core.js:685:41)
    at Object.encrypt (C:\Users\Mickell\Desktop\CPHR\node_modules\crypto-js\cipher-core.js:201:59)

Questions: can someone explain if the hex encoded version of the ECDH client's private key suffices? Or is that completely negligible and its the private key as buffer I should pass in and how? Thank you for your time :).

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