# std.hash

Digests and checksums: SHA-256/512, HMAC-SHA256, CRC32, and FNV-1a.

```tea
use hash from "std.hash"
```

Examples may be fragments requiring the module import or additional setup.

## std.hash.sha256

```tea
pub def sha256(text: String) -> String
```

Compute the SHA-256 digest of UTF-8 text as lowercase hex.

```tea
use hash from "std.hash"

@println(hash.sha256("hello"))
# 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
```

## std.hash.sha256_bytes

```tea
pub def sha256_bytes(data: List[Int]) -> List[Int]
```

Compute the SHA-256 digest of bytes.

```tea
use hash from "std.hash"
use encoding from "std.encoding"

const digest = hash.sha256_bytes([104, 101, 108, 108, 111])
@println(encoding.hex_encode(digest) == hash.sha256("hello")) # true
```

## std.hash.sha512

```tea
pub def sha512(text: String) -> String
```

Compute the SHA-512 digest of UTF-8 text as lowercase hex.

## std.hash.sha512_bytes

```tea
pub def sha512_bytes(data: List[Int]) -> List[Int]
```

Compute the SHA-512 digest of bytes.

## std.hash.hmac_sha256

```tea
pub def hmac_sha256(key: String, message: String) -> String
```

Compute an HMAC-SHA256 tag over UTF-8 text as lowercase hex.

```tea
use hash from "std.hash"

const tag = hash.hmac_sha256("example-key", "message")
@println(@len(tag)) # 64 hexadecimal characters
```

## std.hash.hmac_sha256_bytes

```tea
pub def hmac_sha256_bytes(key: List[Int], message: List[Int]) -> List[Int]
```

Compute an HMAC-SHA256 tag over bytes.

## std.hash.crc32

```tea
pub def crc32(text: String) -> Int
```

Compute the CRC32 checksum of UTF-8 text.

```tea
use hash from "std.hash"

@println(hash.crc32("123456789")) # 3421780262
```

## std.hash.crc32_bytes

```tea
pub def crc32_bytes(data: List[Int]) -> Int
```

Compute the CRC32 checksum of bytes.

## std.hash.fnv1a64

```tea
pub def fnv1a64(text: String) -> Int
```

Compute the FNV-1a 64-bit hash of UTF-8 text.

## std.hash.fnv1a64_bytes

```tea
pub def fnv1a64_bytes(data: List[Int]) -> Int
```

Compute the FNV-1a 64-bit hash of bytes.
