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

928
Views
Postman generate crypto hash gives error: TypeError: crypto.createHash is not a function

I am trying to create a Postman pre-requisite script by converting the below TS code.

import crypto from 'crypto';

const createTestingUserHash = (emailAddress: string, timestamp: string, salt: string) =>
  crypto
    .createHash('sha256')
    .update(`testinguserhash::${emailAddress}::${timestamp}::${salt}`)
    .digest('base64');

export const getLoginLink = async (email: string): Promise<string | undefined> => 
{

  const currentTimeStamp = new Date().toISOString();
  const testingHash = createTestingUserHash(email, currentTimeStamp, testingUserSalt);
  .
  .
  .

My Postman script:

const crypto = require('crypto-js');

const signToken = () => {
    const timestamp = "2022-06-23T14:51:34.694Z";
    const salt = "salt_value";
    const email = "testing@test.io";

    var hash = crypto.createHash('sha256').update(`testinguserhash::${emailAddress}::${timestamp}::${salt}`).digest("base64");
    return (hash);
}

const signedToken = signToken();
console.log(`successfully generated hash : ${signedToken}`)

I also tried var hash = crypto.createHmac('SHA256', "secret").update("Message").digest('base64'); but Postman throws a similar error.

Can someone help me build this script?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

crypto-js has a completely different but well documented interface compared to node.js crypto library

The equivalent crypto-js code is

const crypto = require('crypto-js');

const signToken = () => {
    const timestamp = "2022-06-23T14:51:34.694Z";
    const salt = "salt_value";
    const emailAddress = "testing@test.io";

    return crypto.SHA256(`testinguserhash::${emailAddress}::${timestamp}::${salt}`).toString(crypto.enc.Base64);
}

const signedToken = signToken();
console.log(`successfully generated hash : ${signedToken}`)
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!