Algorithms

SHA-512/256

SHA-512 from its own start values cut to 32 bytes. Algorand hashes with it. Not SHA-512Half
IDsha512-25606 / 38SHA · 256-bit
Hash / Cryptographic

SHA-512/256

SHA-512 from its own start values, cut to 32 bytes.

Digest
256-bit · 32 bytes
HMAC
takes a key
Security
128-bit collision resistance
Used by
Algorand
4 options, 0 required

Sample

hex
0ac561fac838104e3f2e4ad107b4bee3e938bf15f2b15f009ccccd61a913f017
base64
CsVh+sg4EE4/LkrRB7S+4+k4vxXysV8AnMzNYakT8Bc=

Options

encodingstring
default hex
Output encoding: hex, base64, base64url, binary
keystring
optional
HMAC key; enables HMAC mode
roundsnumber
default 1
How many times to hash, each round hashing the previous digest
chainstring
default bytes
What each round after the first hashes: bytes of the digest, or its lowercase hex

Access

Createcreate("sha512-256")
CLIhashes sha512-256 'hello world'
Tryplayground with the sample above
Kinsha256, sha384, sha512, sha224 +7

A 32-byte SHA-2 that runs on SHA-512's 64-bit words. FIPS 180-4 gives it start values of its own, made by hashing the text SHA-512/256. Algorand uses it for transaction IDs and address checksums.

ts
create("sha512-256").hash("abc").digest;
// "53048e2681941ef99b2e29b76b4c7dabe4c2d0c634fc6d46e0e2f13107e7af23"
create("sha512-half").hash("abc").digest;
// "ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a"

Two 32-byte cuts of SHA-512, two different digests. Which one do you need? SHA-512Half keeps SHA-512's own start values, and the XRP Ledger wants that one. Algorand wants this one. Swap them and you get a digest that looks perfectly fine and matches nothing.

The cut has a bonus. Plain SHA-256 hands out its whole state, so anyone can keep hashing from it, the length extension trick. This one keeps half of its state to itself.