Created
February 17, 2022 12:16
-
-
Save javedbaloch4/1320c657b291d4f89a3e66c605f98fce to your computer and use it in GitHub Desktop.
Hashing SHA256 in JavaScript using crypto-js package.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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