#hash #ascon

no-std ascon-hash256

Implementation of Ascon-Hash256 and Ascon-XOF256

4 releases

Uses new Rust 2024

new 0.5.0-rc.2 Feb 2, 2026
0.5.0-rc.1 Jan 24, 2026
0.5.0-rc.0 Jan 4, 2026
0.0.0 Mar 23, 2025

#2 in #ascon

Download history 1/week @ 2025-10-20 3/week @ 2026-01-12 47/week @ 2026-01-19 22/week @ 2026-01-26

72 downloads per month

Apache-2.0 OR MIT

130KB
252 lines

RustCrypto: Ascon-Hash256 and Ascon-XOF128

crate Docs Build Status Apache2/MIT licensed Rust Version Project Chat

Pure Rust implementation of the lightweight cryptographic hash function Ascon-Hash256 and the extendable output functions (XOF) Ascon-XOF128.

Security Notes

No security audits of this crate have ever been performed.

USE AT YOUR OWN RISK!

Examples

Fixed output size hashing:

use ascon_hash256::{AsconHash256, Digest};
use hex_literal::hex;

let mut hasher = AsconHash256::new();
hasher.update(b"some bytes");
let hash = hasher.finalize();

assert_eq!(hash, hex!("e909c2f6da9cb3028423265c8f23fc2d26bfc0f3db704683ef16b787a945ed68"));

// Hex-encode hash using https://docs.rs/base16ct
let hex_hash = base16ct::lower::encode_string(&hash);
assert_eq!(hex_hash, "e909c2f6da9cb3028423265c8f23fc2d26bfc0f3db704683ef16b787a945ed68");

XOF hashing:

use ascon_hash256::{AsconXof128, ExtendableOutput, Update, XofReader};
use hex_literal::hex;

let mut xof = AsconXof128::default();
xof.update(b"some bytes");
let mut reader = xof.finalize_xof();
let mut dst = [0u8; 5];
reader.read(&mut dst);
assert_eq!(dst, hex!("8c7dd114a0"));

Also, see the examples section in the RustCrypto/hashes readme.

License

The crate is licensed under either of:

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~680KB
~18K SLoC