To calculate the SHA256 hash of a string in TypeScript, you can use the crypto
module provided by Node.js. Here is an example function that takes a string input and returns its SHA256 hash:
index.ts168 chars8 lines
Here's how to use the sha256
function to calculate the hash of a string:
index.ts154 chars4 lines
Note that the crypto
module is only available in Node.js, so this code won't work in a web browser without using a third-party library.
gistlibby LogSnag