Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

931
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda