Skip to main content

sha1

Function sha1 

Source
pub fn sha1(message: &[u8]) -> [u8; 20]
Expand description

SHA-1 of a byte string, for the one thing RFC 6455 specifies it for.

The handshake is the only place this algorithm appears in this crate, and it is not used for anything that needs to be hard to forge — the accept value proves the peer read the request, nothing more. Everything this executable hashes for real (the registry fingerprint, the index, the artifacts) is SHA-256.

use majordomus_cli::http::ws::sha1;
let digest: String = sha1(b"abc").iter().map(|b| format!("{b:02x}")).collect();
assert_eq!(digest, "a9993e364706816aba3e25717850c26c9cd0d89d");
let empty: String = sha1(b"").iter().map(|b| format!("{b:02x}")).collect();
assert_eq!(empty, "da39a3ee5e6b4b0d3255bfef95601890afd80709");