The std/crypto module provides cryptographic primitives and hashing algorithms.
Implementation of the SHA1 hashing algorithm.
import "std/crypto/sha1.zc"
fn main() {
let data = "Hello";
let digest = Sha1::hash((u8*)data, 5);
// digest.bytes is u8[20]
}
| Method | Signature | Description |
|---|---|---|
| hash | Sha1::hash(data: u8*, len: usize) -> Sha1 |
Computes the SHA1 hash of the given data. |
Implementation of the modern SHA-256 hashing algorithm (FIPS 180-4).
import "std/crypto/sha256.zc"
fn main() {
let hash = Sha256::hash("hello world");
// hash is hexadecimal string
}
| Method | Signature | Description |
|---|---|---|
| hash | Sha256::hash(data: char*) -> String |
Computes the SHA-256 hash of the given string and returns it as a Hex string. |