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

153
Views
How to convert string from ENV to hex in JavaScript?

In my .env file I have such environmental variable:

CRYPTO_KEY_SHORT=\x12\x34\x56\x78\x9A\x12\x32\xE3

I use this string as a key in code, like this:

const decryptedHash = cryptoService.decryptHex(confirmToken, `${process.env.CRYPTO_KEY_SHORT}`, null)

And here is the problem, it doesn't work this way, every time I get error - Error: Invalid key length, but if I hardcode this it work:

const decryptedHash = cryptoService.decryptHex(confirmToken, "\x12\x34\x56\x78\x9A\x12\x32\xE3", null)

So, after putting such variable to .env how can I use it?

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