Skip to content
CryoCryo home
Stdlibencoding

sha1

import std::encoding::sha1; · source

SHA-1

function sha1(data: u8*, len: u64, out: u8*) -> void;
const DIGEST_LEN: u64 = 20;

RFC 3174. sha1 hashes len bytes and writes a DIGEST_LEN-byte digest to out, which must point to at least that much space.

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-Accept value. Do not use it as a security primitive. Having a pure Cryo implementation is what keeps plain ws:// 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.