Here's an implementation of SHA-256 in vanilla JavaScript that can be used to hash a string:
index.tsx295 chars10 lines
Note that this uses TextEncoder
to encode the string as a Uint8Array
buffer so it can be passed to crypto.subtle.digest
. If you need to support older browsers without TextEncoder
, you'll need to use a polyfill or a different encoding method.
gistlibby LogSnag