Documentation
¶
Overview ¶
Package hash provides hashing utilities:
- Standard hashes: MD5, SHA-1, SHA-256, SHA-512
- HMAC: HMAC-SHA256, HMAC-SHA512
- CRC: CRC32, CRC64
- MurmurHash3: 32-bit and 128-bit (x64) non-cryptographic hashes
- xxHash: xxHash64 and xxHash32 non-cryptographic hashes
- Hash file/stream helpers
Quick start ¶
hash.MD5Hex([]byte("hello")) // "5d41402abc4b2a76b9719d911017c592"
hash.SHA256Hex([]byte("hello"))
hash.HMACSHA256Hex([]byte("data"), key)
hash.Murmur3_32Hex([]byte("hello"), 0)
hash.XXHash64Hex([]byte("hello"), 0)
Index ¶
- func Adler32(data []byte) uint32
- func CRC16(data []byte) uint16
- func CRC16CCITT(data []byte) uint16
- func CRC16Hex(data []byte) string
- func CRC32(data []byte) uint32
- func CRC32Hex(data []byte) string
- func CRC64(data []byte) uint64
- func CRC64Hex(data []byte) string
- func FNV1a32(data []byte) uint32
- func FNV1a64(data []byte) uint64
- func HMACEqual(a, b []byte) bool
- func HMACSHA256(data, key []byte) []byte
- func HMACSHA256Hex(data, key []byte) string
- func HMACSHA512(data, key []byte) []byte
- func HMACSHA512Hex(data, key []byte) string
- func Hex(ht HashType, data []byte) (string, error)
- func HexUpper(ht HashType, data []byte) (string, error)
- func MD5(data []byte) []byte
- func MD5File(path string) ([]byte, error)
- func MD5FileHex(path string) (string, error)
- func MD5Hex(data []byte) string
- func MD5Reader(r io.Reader) ([]byte, error)
- func MD5String(s string) string
- func Murmur3_32(data []byte, seed uint32) uint32
- func Murmur3_32Hex(data []byte, seed uint32) string
- func Murmur3_128(data []byte, seed uint32) (uint64, uint64)
- func Murmur3_128Hex(data []byte, seed uint32) string
- func SHA1(data []byte) []byte
- func SHA1Hex(data []byte) string
- func SHA1String(s string) string
- func SHA256(data []byte) []byte
- func SHA256File(path string) ([]byte, error)
- func SHA256FileHex(path string) (string, error)
- func SHA256Hex(data []byte) string
- func SHA256Reader(r io.Reader) ([]byte, error)
- func SHA256String(s string) string
- func SHA512(data []byte) []byte
- func SHA512Hex(data []byte) string
- func SHA512String(s string) string
- func XXHash32(data []byte, seed uint32) uint32
- func XXHash32Hex(data []byte, seed uint32) string
- func XXHash64(data []byte, seed uint64) uint64
- func XXHash64Hex(data []byte, seed uint64) string
- type HashType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CRC16CCITT ¶
CRC16CCITT returns the CRC16-CCITT checksum of data (poly 0x1021).
func HMACSHA256 ¶
HMACSHA256 returns the HMAC-SHA256 of data using key.
func HMACSHA256Hex ¶
HMACSHA256Hex returns the HMAC-SHA256 of data as a hex string.
func HMACSHA512 ¶
HMACSHA512 returns the HMAC-SHA512 of data using key.
func HMACSHA512Hex ¶
HMACSHA512Hex returns the HMAC-SHA512 of data as a hex string.
func MD5FileHex ¶
MD5FileHex returns the MD5 hash of a file as a hex string.
func Murmur3_32 ¶
Murmur3_32 returns the MurmurHash3 32-bit hash of data with the given seed.
func Murmur3_32Hex ¶
Murmur3_32Hex returns the MurmurHash3 32-bit hash as a hex string.
func Murmur3_128 ¶
Murmur3_128 returns the MurmurHash3 128-bit hash (x64) as two uint64 values.
func Murmur3_128Hex ¶
Murmur3_128Hex returns the MurmurHash3 128-bit hash as a hex string.
func SHA1String ¶
SHA1String returns the SHA-1 hash of a string as a hex string.
func SHA256File ¶
SHA256File returns the SHA-256 hash of a file.
func SHA256FileHex ¶
SHA256FileHex returns the SHA-256 hash of a file as a hex string.
func SHA256Reader ¶
SHA256Reader returns the SHA-256 hash of a reader.
func SHA256String ¶
SHA256String returns the SHA-256 hash of a string as a hex string.
func SHA512String ¶
SHA512String returns the SHA-512 hash of a string as a hex string.
func XXHash32Hex ¶
XXHash32Hex returns the xxHash32 hash as a hex string.
func XXHash64Hex ¶
XXHash64Hex returns the xxHash64 hash as a hex string.