Module: crypto.sha1

Source: ./crypto/sha1.reef


Overview

crypto/sha1 - SHA-1 message-digest algorithm

Implements SHA-1 (FIPS 180-4) hash function. Produces 160-bit (20-byte) digest.

Note: SHA-1 is deprecated for security purposes but still used for integrity checking and git commit hashes.

Usage: import crypto.sha1 let hash = sha1("Hello, World!") // Returns 40-char hex string let hash = sha1_hex("Hello, World!") // Same as sha1()


Functions

fn sha1_k(t: int): int

Get K constant for round t (0-79)

fn sha1_ch(x: int, y: int, z: int): int

Ch(x, y, z) = (x AND y) XOR (NOT x AND z) - rounds 0-19

fn sha1_parity(x: int, y: int, z: int): int

Parity(x, y, z) = x XOR y XOR z - rounds 20-39, 60-79

fn sha1_maj(x: int, y: int, z: int): int

Maj(x, y, z) = (x AND y) XOR (x AND z) XOR (y AND z) - rounds 40-59

fn sha1(data: string): string

fn sha1_hex(data: string): string

fn sha1_hex_lower(data: string): string

fn sha1_bytes(data: [uint8]): string

SHA-1 for binary data (byte arrays) - handles null bytes correctly

fn sha1_hex_digits(): string

fn sha1_state_to_hex(state: [int]): string

Convert SHA-1 state to 40-char hex string (big-endian byte order)


Procedures

proc sha1_process_block(state: [int], block: [int])


Generated by reefc doc