- Go 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .github | ||
| docs | ||
| tests | ||
| .gitattributes | ||
| .gitignore | ||
| .markdownlint-cli2.jsonc | ||
| CHANGELOG.md | ||
| COPYING.md | ||
| examples_test.go | ||
| extensible.go | ||
| fixed.go | ||
| go.mod | ||
| go.sum | ||
| hash.go | ||
| LICENSE | ||
| README.md | ||
| SECURITY.md | ||
Hash - High-level Cryptographic Hash Wrappers for Go
This package provides High-level Go wrappers for standard hash functions, unifying a set of common cryptographic hash operations behind a single API, allowing callers to switch between algorithms with minimal code changes while relying on well-maintained and secure backends. It unifies Merkle-Damgård and extendable-output functions behind a single API, providing HMAC and HKDF helpers along with consistent metadata (block sizes, security strength, availability). Hashers are immutable handles that produce fresh state, preventing cross-call contamination and enforcing sane defaults for sizes.
HMAC key sizes longer than the hash function's block size create a panic. Standard HMAC hashes longer keys, but that reduces the effective security level advertised by the original key size. We encourage using appropriate key lengths.
Import
import "rtlabs.tech/gms-hash"
Quick Start
- Quickly hash data:
message := []byte("message")
output := hash.SHA256.Hash(message)
- HMAC
message := []byte("message")
key := []byte("key")
hmac := hash.SHA256.GetHashFunction().Hmac(message, key)
- If you have an identifier from the crypto package, it's easy:
id := crypto.SHA256
message := []byte("message")
output := hash.FromCrypto(id).Hash(message)
See examples_test.go for additional HMAC, HKDF extract/expand, and metadata usage patterns.
Versioning
SemVer is used for versioning. For the versions available, see the tags on the repository.
Copyright and License
Code and Documentation Copyright © 1994-2026, Stephen Kapp and Reaper Technologies Limited. All Rights Reserved.