.\crypto.axec
pub def rotr(x: i32, n: i32): i32
SHA256 digest size in bytes
SHA1 digest size in bytes
MD5 digest size in bytes
Represents a SHA256 hash digest
Right rotate a 32-bit unsigned integer
pub def shr(x: i32, n: i32): i32
Right shift with proper unsigned handling
pub def ch(x: i32, y: i32, z: i32): i32
SHA-256 Ch function: (x AND y) XOR (NOT x AND z)
pub def maj(x: i32, y: i32, z: i32): i32
SHA-256 Maj function: (x AND y) XOR (x AND z) XOR (y AND z)
pub def sigma0(x: i32): i32
SHA-256 Σ0 function
pub def sigma1(x: i32): i32
SHA-256 Σ1 function
pub def sigma_lower0(x: i32): i32
SHA-256 σ0 function (lowercase sigma)
pub def sigma_lower1(x: i32): i32
SHA-256 σ1 function (lowercase sigma)
pub def xor_op(a: i32, b: i32): i32
SHA-256 round constants (first 32 bits of the fractional parts of the cube roots of the first 64 primes) SHA-256 initial hash values (first 32 bits of the fractional parts of the square roots of the first 8 primes) XOR operation
pub def and_op(a: i32, b: i32): i32
AND operation
pub def or_op(a: i32, b: i32): i32
OR operation
pub def not_op(a: i32): i32
NOT operation
pub def add_wrap(a: i32, b: i32): i32
Add with wrapping
pub def bytes_to_u32(b0: i32, b1: i32, b2: i32, b3: i32): i32
Convert 4 bytes to i32 (big-endian)
pub def u32_byte(value: i32, pos: i32): i32
Extract byte from i32 at position (0-3, big-endian)
pub def sha256_digest_empty(): SHA256Digest
Create an empty SHA256Digest with all bytes initialized to zero
pub def sha256_process_block(block: ref i32, h: ref i32)
Process a single 512-bit block of data
pub def sha256(data: ref char, len: i32): SHA256Digest
Compute SHA-256 hash of input data
pub def simple_hash(data: ref char, len: i32): SHA256Digest
Simple hash function for demonstration (NOT cryptographically secure - use sha256 instead)
pub def byte_to_hex(byte_val: i32, arena: ref Arena): string
Converts a single byte to a two-character hex string
pub def sha256_to_hex(digest: SHA256Digest, arena: ref Arena): string
Converts a SHA256 digest to a lowercase hex string (64 characters)
pub def constant_time_compare(buf1: i32, buf2: i32, len: i32): bool
Constant-time memory comparison for cryptographic purposes Returns true if buffers are equal. Prevents timing attacks.
pub def sha256_equals(digest1: SHA256Digest, digest2: SHA256Digest): bool
Constant-time comparison of two SHA256 digests
pub def sha256_zero(digest: ref SHA256Digest)
Securely zero out a digest (for clearing sensitive data)
pub def sha256_validate(digest: SHA256Digest): bool
Validate that a digest has valid byte values (0-255)
pub def base64_encode(data: ref char, len: i32, arena: ref Arena): string
Base64 encoding table Base64-encode a block of bytes.
Input: raw bytes (char*) and length. Output: newly allocated string in arena.
pub def base64_value(c: i32): i32
Convert a Base64 character to its value. Returns -1 if invalid.
pub def base64_decode(data: ref char, len: i32, arena: ref Arena): string
Base64 decode, matching the string + arena style.