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

222
Views
Ninguna sobrecarga coincide con esta llamada. La última sobrecarga dio el siguiente error en mecanografiado

Escribí el código sobre encriptar la cadena que pasa en la función cryto con el archivo .env pero aparece la línea de error, no sé qué significa eso. Configuro los valores en el archivo .env con el entorno y los exporto por defecto y los uso en caso de que los necesite, pero la línea de error muestra "Ninguna sobrecarga coincide con esta llamada. La última sobrecarga dio el siguiente error.

 Argument of type 'string | undefined' is not assignable to parameter of type 'WithImplicitCoercion<string> | { [Symbol.toPrimitive](hint: "string"): string; }'. Type 'undefined' is not assignable to type 'WithImplicitCoercion<string> | { [Symbol.toPrimitive](hint: "string"): string; }"

como esto.

 import { randomBytes, createCipheriv, createDecipheriv } from "crypto"; import environment from "../environment"; const ENCRYPTION_KEY = environment.encrypt_Key; // const enc = "klyH2NOdPmmFPtdCAHIIGgjMowUUd69P"; const IV_LENGTH = 16; export const encrypt = async (text: string) => { try { let iv = randomBytes(IV_LENGTH); let cipher = createCipheriv("aes-256-cbc", Buffer.from(ENCRYPTION_KEY), iv); let encrypted = Buffer.concat([cipher.update(text), cipher.final()]); return `${iv.toString("hex")}:${encrypted.toString("hex")}`; } catch (e) { console.error(e); } };
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Lo más probable es que su environment esté definido de tal manera que devuelva una string o undefined para una clave. Una forma de manejarlo es verificar eso y arrojar un error como este:

 export const encrypt = async (text: string) => { // check if ENCRYPTION_KEY is set if(!ENCRYPTION_KEY) { throw new Error("encrypt_Key is not set"); } try { let iv = randomBytes(IV_LENGTH); let cipher = createCipheriv("aes-256-cbc", Buffer.from(ENCRYPTION_KEY), iv); let encrypted = Buffer.concat([cipher.update(text), cipher.final()]); return `${iv.toString("hex")}:${encrypted.toString("hex")}`; } catch (e) { console.error(e); } };
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!