A sponge-based secure hash function that uses AES-256 as its internal PRF. https://lordmulder.github.io/sponge-hash-aes256/
  • Rust 84.2%
  • Shell 7.5%
  • Batchfile 4%
  • Makefile 3%
  • NSIS 1%
  • Other 0.3%
Find a file
2026-05-31 00:22:02 +02:00
.assets Updated README file. 2025-12-29 18:27:17 +01:00
.build Github workflow (CI): Updated 'cross-platform-actions' image for 'openbsd' to version 7.9. 2026-05-30 19:26:29 +02:00
.github/workflows Github workflow (CI): Re-wrote all 'cross-platform-actions' jobs to use the 'cpa.sh' helper script instead of using the deprecated 'run:' parameter. 2026-05-30 22:36:22 +02:00
app Bump version + updated changelog. 2026-05-31 00:22:02 +02:00
lib Bump version + updated changelog. 2026-05-31 00:22:02 +02:00
.gitattributes Small improvement to the Makefile for the Linux platform. 2025-12-14 22:36:43 +01:00
.gitignore Simplified RUSTFLAGS for NetBSD cross-build. 2025-10-06 20:59:34 +02:00
.rustfmt.toml Added workspace manifest file in the repository root directory. 2025-12-19 01:20:36 +01:00
Cargo.lock Bump version + updated changelog. 2026-05-31 00:22:02 +02:00
Cargo.toml Added workspace manifest file in the repository root directory. 2025-12-19 01:20:36 +01:00
CHANGELOG.md Bump version + updated changelog. 2026-05-31 00:22:02 +02:00
LICENSE Updated copyright year. 2026-01-01 21:47:45 +01:00
README-cargo.md Bump version + updated changelog. 2026-05-31 00:22:02 +02:00
README.md Bump version + updated changelog. 2026-05-31 00:22:02 +02:00
SECURITY.md Bump version + updated changelog. 2026-05-06 21:52:50 +02:00

SpongeHash-AES256

A sponge-based secure hash function that uses AES-256 as its internal PRF.

This hash function has a variable output size and can produce outputs of any non-zero size.

Library

The “core” hash algorithm is implemented in the sponge-hash-aes256 crate.

Installation

In order to use this crate, add it under [dependencies] to your Cargo.toml:

[dependencies]
sponge-hash-aes256 = "1.10.2"

Usage

Here is a simple example that demonstrates how to use SpongeHash256 in your code:

use hex::encode_to_slice;
use sponge_hash_aes256::{DEFAULT_DIGEST_SIZE, SpongeHash256};

fn main() {
    // Create new hash instance
    let mut hash = SpongeHash256::default();

    // Process message
    hash.update(b"The quick brown fox jumps over the lazy dog");

    // Retrieve the final digest
    let digest = hash.digest::<DEFAULT_DIGEST_SIZE>();

    // Encode to hex
    let mut hex_buffer = [0u8; 2usize * DEFAULT_DIGEST_SIZE];
    encode_to_slice(&digest, &mut hex_buffer).unwrap();

    // Print the digest (hex format)
    println!("0x{}", str::from_utf8(&hex_buffer).unwrap());
}

Documentation

Please refer to the sponge-hash-aes256 documentation for more details! 💡

Command-line tool

The sponge256sum command-line tool, similar to sha256sum and friends:

Usage

This command-line application can be used as follows:

Usage: sponge256sum [OPTIONS] [FILES]...

Arguments:
  [FILES]...  Files to be processed

Options:
  -b, --binary           Read the input file(s) in binary mode, i.e., default mode
  -t, --text             Read the input file(s) in text mode
  -c, --check            Read and verify checksums from the provided input file(s)
  -d, --dirs             Enable processing of directories as arguments
  -r, --recursive        Recursively process the provided directories (implies -d)
  -x, --cross-dev        Descend into directories on other devices (implies -r)
  -a, --all              Iterate all kinds of files, instead of just regular files
  -k, --keep-going       Continue processing even if errors are encountered
  -l, --length <LENGTH>  Digest output size, in bits (default: 256, maximum: 2048)
  -i, --info <INFO>      Include additional context information
  -s, --snail...         Enable "snail" mode, i.e., slow down the hash computation
  -q, --quiet            Do not output any error messages or warnings
  -p, --plain            Print digest(s) in plain format, i.e., without file names
  -0, --null             Separate digest(s) by NULL characters instead of newlines
  -m, --multi-threading  Enable multi-threaded processing of input files
  -f, --flush            Explicitly flush 'stdout' stream after printing a digest
  -T, --self-test        Run the built-in self-test (BIST)
  -h, --help             Print help
  -V, --version          Print version

If no input files are specified, reads input data from the 'stdin' stream.
Returns a non-zero exit code if any errors occurred; otherwise, zero.

Documentation

Please refer to the sponge256sum documentation for more details! 💡

Algorithm

This section provides additional details about the SpongeHash-AES256 algorithm.

Internal state

The state has a total size of 384 bits, consisting of three 128-bit blocks, and is initialized to all zeros at the start of the computation. Only the upper 128 bits are directly used for input and output operations.

Update function

The “update” function, which absorbs input blocks into the state and squeezes the corresponding output from it, is defined as follows, where input[i] denotes the i-th input block and output[k] the k-th output block:

Permutation function

The “permutation” function, applied to scramble the state after each absorbing or squeezing step, is defined as follows, where AES-256 denotes the AES cipher with a key size of 256 bits and a block size of 128 bits.

The constants const_0 and const_1 are defined as full blocks filled with 0x5C and 0x36, respectively.

Finalization

The padding of the final input block is performed by first appending a single 1 bit, followed by the minimal number of 0 bits needed to make the total message length a multiple of the block size.

Following the final input block, a 128-bit block filled entirely with 0x6A bytes is absorbed into the state.

Platform support

This crate uses Rust edition 2021, and requires rustc version 1.89.0 or newer.

The following targets are officially supported, other platforms may function but are not guaranteed:

  • Linux
  • Windows
  • macOS
  • *BSD (FreeBSD, OpenBSD, NetBSD, DragonFlyBSD, etc.)
  • Haiku OS
  • Solaris / Illumos (OmniOS, OpenIndiana)

See also

Official Git mirrors are available here:

Additional resources you may find helpful:

License

This software is released under the BSD Zero Clause (“0BSD”) License.

Copyright (C) 2025-2026 by LoRd_MuldeR <mulder2@gmx.de>.