pruefung

Crates.iopruefung
lib.rspruefung
version0.2.1
sourcesrc
created_at2017-07-20 15:25:43.239075
updated_at2017-11-23 12:05:10.746472
descriptionChecksums in pure Rust, with no_std available, implementing the Hasher trait.
homepage
repositoryhttps://github.com/althonos/pruefung
max_upload_size
id24280
size92,770
Martin Larralde (althonos)

documentation

README

pruefung

Checksums in pure Rust.

TravisCI Source Crate Documentation CargoMake Changelog SayThanks

THIS LIBRARY DOES NOT PROVIDE A STABLE API YET !

Usage

Add this crate to the Cargo.toml:

[dependencies]
pruefung = "^0.1.0"

Check out the Sums section to see the minimal required version you need depending on the algorithm you wish to use.

All the checksums are implemented using the same logic as the hashes crate of the RustCrypto project, implementing the digest::Digest, and the core::hasher::Hasher traits when possible (less than 64 bits in the output).

Then, to compute a hash, for instance a CRC32 (Ethernet standard):

extern crate pruefung;
use std::hash::Hasher;

let mut hasher = pruefung::crc32::CRC32();   // Instantiate a hasher
let data = b"Hello, world !";

hasher.write(data);                          // Feed the hasher
hasher.write("String data".as_bytes());      // (possibly multiple times)

let hash = hasher.finish();                  // Consume the hasher
println!("Result: {:x}", hash)               // print the result as native hex

Dependencies

The crate itself is no_std, but provides digest::Digest implementations for convenience and integration with the hashes crate. Those bindings can be scrapped off however by disabling the default features of the crates, adding the following line to yout Cargo.toml:

[dependencies.pruefung]
version = "^0.1.0"
default-features = false

Sums

Latest version of the crate implements the following checksums:

Algorithm since implemented as
Adler32 0.1.0 ::adler32::Adler32
BSD checksum 0.2.0 ::bsd::Bsd
CRC32 0.2.0 ::crc::crc32::CRC32
CRC32C 0.2.0 ::crc::crc32::CRC32C
Fletcher16 0.1.0 ::fletcher16::Fletcher16
FNV0-32 0.2.0 ::fnv::fnv32::Fnv32z
FNV1-32 0.2.0 ::fnv::fnv32::Fnv32
FNV1a-32 0.2.0 ::fnv::fnv32::Fnv32a
FNV0-64 0.2.0 ::fnv::fnv64::Fnv64z
FNV1-64 0.2.0 ::fnv::fnv64::Fnv64
FNV1a-64 0.2.0 ::fnv::fnv64::Fnv64a
SysV checksum 0.1.0 ::sysv::SysV
UNIX checksum 0.2.0 ::unix::Unix

These checksums are NOT cryptographically secure. They should not be used for something else than data validation against accidental modifications: an attacker could easily forge a file to pass any of these checksums ! For secure checksums, look at the hashes implemented by the RustCrypto team.

Why pruefung ?

I was in Switzerland when I started this project. Yet, I don't really speak german. But a slug version of zyklische-redundanzprüfung seemed like a nice name, instead of another checksum, cksum, checksums, crc, etc. crate.

Commit count: 110

cargo fmt