Algorithms
SHA-256
The SHA-2 hash everything agrees on. 32 bytes with HMAC and the default when nobody told you otherwise
Hash / Cryptographic
SHA-256
The default. Certificates, signatures, Bitcoin.
- Digest
- 256-bit · 32 bytes
- HMAC
- takes a key
- Security
- 128-bit collision resistance
- Family
- 16 in cryptographic
2 options, 0 required
Sample
- hex
- b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9
- base64
- uU0nuZNNPgilLlLX2n2r+sSE7+N6U4DukIj3rOLvzek=
Options
Access
- Create
create("sha256") - CLI
hashes sha256 'hello world' - Tryplayground with the sample above
- Kinsha384, sha512, sha512-half, sha3-256 +11
The default, and for good reason. Certificates, signatures, Git's next object format, Bitcoin's proof of work, half the checksum files on the internet. If two systems have to agree on a digest and nobody said which, it's this one.
create("sha256").hash("abc").digest;
// "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"
create("sha256").hash("").digest;
// "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
create("sha256").hash("The quick brown fox jumps over the lazy dog", { key: "key" }).digest;
// "f7bc83f430538424b13298e6aa6fb143ef4d59a14946175997479dbc2d1a3cd8"
The first two are the FIPS 180 vector and the empty string, the third is the HMAC one Wikipedia quotes. If a SHA-256 of "" doesn't start with e3b0c442, something upstream added a newline.
Bitcoin runs it twice, that's HASH256. Under RIPEMD-160 it becomes HASH160.