Expand description
A minimal implementation of SHA1 for rust.
This implementation supports no_std which is the default mode. The following features are available and can be optionally enabled:
serde
: when enabled theDigest
type can be serialized.std
: when enabled errors from this library implementstd::error::Error
and thehexdigest
shortcut becomes available.
ยงExample
let mut m = sha1_smol::Sha1::new();
m.update(b"Hello World!");
assert_eq!(m.digest().to_string(),
"2ef7bde608ce5404e97d5f042f95f89f1c232871");
The sha1 object can be updated multiple times. If you only need to use it once you can also use shortcuts (requires std):
assert_eq!(sha1_smol::Sha1::from("Hello World!").hexdigest(),
"2ef7bde608ce5404e97d5f042f95f89f1c232871");
Modulesยง
- simd ๐
Structsยง
- Blocks ๐
- Digest
- Digest generated from a
Sha1
instance. - Digest
Parse Error - Indicates that a digest couldnโt be parsed.
- Sha1
- Represents a Sha1 hash object in memory.
- Sha1
State ๐
Constantsยง
- DEFAULT_
STATE ๐ - DIGEST_
LENGTH - The length of a SHA1 digest in bytes
- K0 ๐
- K1 ๐
- K2 ๐
- K3 ๐
Functionsยง
- as_
block ๐ - sha1_
digest_ ๐round_ x4 - Emulates
llvm.x86.sha1rnds4
intrinsic. Performs 4 rounds of the message block digest. - sha1_
first ๐ - Not an intrinsic, but gets the first element of a vector.
- sha1_
first_ ๐add - Not an intrinsic, but adds a word to the first element of a vector.
- sha1_
first_ ๐half - Emulates
llvm.x86.sha1nexte
intrinsic. - sha1msg1 ๐
- Emulates
llvm.x86.sha1msg1
intrinsic. - sha1msg2 ๐
- Emulates
llvm.x86.sha1msg2
intrinsic. - sha1rnds4c ๐
- Not an intrinsic, but helps emulate
llvm.x86.sha1rnds4
intrinsic. - sha1rnds4m ๐
- Not an intrinsic, but helps emulate
llvm.x86.sha1rnds4
intrinsic. - sha1rnds4p ๐
- Not an intrinsic, but helps emulate
llvm.x86.sha1rnds4
intrinsic.