Skip to content

Instantly share code, notes, and snippets.

@javedbaloch4
Created February 17, 2022 12:16
Show Gist options
  • Save javedbaloch4/1320c657b291d4f89a3e66c605f98fce to your computer and use it in GitHub Desktop.
Save javedbaloch4/1320c657b291d4f89a3e66c605f98fce to your computer and use it in GitHub Desktop.
Hashing SHA256 in JavaScript using crypto-js package.
const { SHA256 } = require('crypto-js')
const name = "Javed"
const transactionHistory = {
id: 223423424,
name: 'Javed-123',
amount: 24234234
}
const generateHash = (obj) => {
return SHA256(JSON.stringify(obj))
}
console.log( ` SHA256 Hash: ${generateHash(name)} ` )
console.log( ` SHA256 Hash: ${generateHash(transactionHistory)} ` )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment