Crate sha1_smol

Source
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 the Digest type can be serialized.
  • std: when enabled errors from this library implement std::error::Error and the hexdigest 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.
DigestParseError
Indicates that a digest couldnโ€™t be parsed.
Sha1
Represents a Sha1 hash object in memory.
Sha1State ๐Ÿ”’

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.