sha1
import std::encoding::sha1; · source
Free Functions
function sha1(data: u8*, len: u64, out: u8*) -> void;
function sha1(data: u8*, len: u64, out: u8*) -> void;Hash len bytes at data, writing the 20-byte digest to out. out must point to at least DIGEST_LEN bytes.
An implementation of RFC 3174.
SHA-1 is cryptographically broken for collision resistance. It ships here only because the WebSocket handshake (RFC 6455) hard-codes it for the
Sec-WebSocket-Acceptvalue. Do not use it as a security primitive. Having a pure Cryo implementation is what keeps plainws://free of any external crypto dependency — no OpenSSL link required.
For hashing in the non-cryptographic sense — map keys, fingerprints — use core::hash. For key material, tokens, and nonces, use random::SecureRng.
Constants
const DIGEST_LEN: u64 = 20;const NAME: Type = value;At module level, a true compile-time constant, conventionally SCREAMING_SNAKE_CASE. (mut at module level declares mutable global state instead.)
const DIGEST_LEN: u64 = 20;import a::b;
import a::b::{ X, Y };
import a::b as c;
import a::b::*;Brings a module, or selected items from it, into scope. One path per declaration: use the brace form for several items, as to alias, and * for everything public (prefer the brace form; wildcards invite name collisions).
function name<T>(param: Type) -> Ret { ... }Declares a function. Parameters are written name: Type and are never inferred; the return type follows -> and defaults to void. Declaration order does not matter: every signature is collected before any body is checked, so functions may call each other freely and recurse.
function sha1(data: u8*, len: u64, out: u8*) -> voidHash len bytes at data, writing the 20-byte digest to out. out must point to at least DIGEST_LEN bytes.
(parameter) data: u8*(parameter) len: u64(parameter) out: u8*const DIGEST_LEN: u64 = 20;type struct WebSocket<S> {
conn: BufStream<S>;
is_client: boolean;
closed: boolean;
}