Skip to content
CryoCryo home
Stdlibencoding

sha1

import std::encoding::sha1; · source

Free Functions

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-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.

Constants

const DIGEST_LEN: u64 = 20;