0

Is there any way i can use nodejs "crypto" module in javascript without actually using node.

Or is there any similar javascript library that does all the things that "crypto" does

Like i neeed the below code in javascript with the help of nodejs

  var crypto = require('crypto'),
     hash = crypto.createHash('sha256'),
     hmac = crypto.createHmac('sha256', someKey);

basically i need to replicate below in javascript without using node at all

var bytesToSign = hash.update(stringToSign).digest();
gevorg
  • 4,835
  • 4
  • 35
  • 52
Amit
  • 6,839
  • 21
  • 56
  • 90
  • Is there a specific reason you want to use the crypto module but not node? If it's JS based encryption you're looking for then there are other choices available. – Jamie Keeling May 08 '12 at 07:58

1 Answers1

1

node.js crypto module is based on openssl library

you can try this native js implementation of sha256 digest

Andrey Sidorov
  • 24,905
  • 4
  • 62
  • 75
  • basically i need to replicate below in javascript without using node at all "var bytesToSign = hash.update(stringToSign).digest();". Not sure how to do this without using node – Amit May 08 '12 at 08:40
  • with the mentioned script its just `digest = sha256_digest(stringToSign)`, no node dependency – Andrey Sidorov May 08 '12 at 08:49