Algorithms

SHAKE128

The FIPS 202 sponge at 128-bit security. Squeezes 32 bytes unless you ask for another length
IDshake12810 / 48SHA · 256-bit
Hash / Cryptographic

SHAKE128

The sponge that stops when you say so.

Digest
256-bit · 32 bytes
HMAC
no key mode
Security
128-bit security from 32 bytes of output up; shorter outputs give half their bits against collisions
Used by
ML-KEM, ML-DSA
4 options, 0 required

Sample

hex
3a9159f071e4dd1c8c4f968607c30942e120d8156b8b1e72e0d376e8871cb8b8
base64
OpFZ8HHk3RyMT5aGB8MJQuEg2BVrix5y4NN26IccuLg=

Options

encodingstring
default hex
Output encoding: hex, base64, base64url, binary
outputLengthnumber
default 32
Bytes to squeeze, any whole number from 0
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("shake128")
CLIhashes shake128 'hello world'
Tryplayground with the sample above
Kinsha256, sha384, sha512, sha224 +9

Need a digest with a length you choose? SHAKE128 keeps squeezing until you tell it to stop. ML-KEM and ML-DSA lean on it all day. It's a FIPS 202 extendable output function. It uses the same Keccak sponge as SHA-3, with different padding. SHA3-256 is the same sponge with the length welded on.

outputLength sets the number of output bytes. It accepts any whole number from zero.

The default is 32 bytes. That's SHAKE128's full 128-bit security. Node's own default is 16, half of it, and OpenSSL 3 won't guess at all without -xoflen. Shorter output gives less collision resistance. At 16 bytes, it's 64 bits. Use the default unless you have a reason to shorten it.

ts
create("shake128").hash("abc").digest;
// "5881092dd818bf5cf8a3ddb793fbcba74097d5c526a6d35f97b83351940f2cc8"
create("shake128").hash("abc", { outputLength: 16 }).digest;
// "5881092dd818bf5cf8a3ddb793fbcba7"

Those 16 bytes are the start of the longer output. Less output means less of the same stream, not another hash. So two lengths of one input aren't independent. Don't treat them as two keys.

The CLI flag is --output-length. Agent tools cap output at 1024 bytes per call. They also cap rounds times outputLength at 64 million bytes. Library callers can choose any length. Results report outputLength in their options only when you set it.

For bytes without the registry, import shake128(bytes, length) from @agntn/hashes/keccak. See Hashing and SHAKE256.