Documentation
¶
Overview ¶
Package hash provides cryptographic hash and hmac functions. It supports multiple hash algorithms including MD2, MD4, MD5, SHA1, SHA2, SHA3, BLAKE2b, BLAKE2s, RIPEMD160, SM3 and so on, with both standard and streaming modes.
Index ¶
- Variables
- type Hasher
- func (h Hasher) ByBlake2b(size int) Hasher
- func (h Hasher) ByBlake2s(size int) Hasher
- func (h Hasher) ByMd2() Hasher
- func (h Hasher) ByMd4() Hasher
- func (h Hasher) ByMd5() Hasher
- func (h Hasher) ByRipemd160() Hasher
- func (h Hasher) BySha1() Hasher
- func (h Hasher) BySha2(size int) Hasher
- func (h Hasher) BySha3(size int) Hasher
- func (h Hasher) BySm3() Hasher
- func (h Hasher) FromBytes(b []byte) Hasher
- func (h Hasher) FromFile(f fs.File) Hasher
- func (h Hasher) FromString(s string) Hasher
- func (h Hasher) ToBase64Bytes() []byte
- func (h Hasher) ToBase64String() string
- func (h Hasher) ToHexBytes() []byte
- func (h Hasher) ToHexString() string
- func (h Hasher) ToRawBytes() []byte
- func (h Hasher) ToRawString() string
- func (h Hasher) WithKey(key []byte) Hasher
Constants ¶
This section is empty.
Variables ¶
var BufferSize = 64 * 1024
BufferSize buffer size for streaming (64KB is a good balance)
Functions ¶
This section is empty.
Types ¶
type Hasher ¶
type Hasher struct {
Error error
// contains filtered or unexported fields
}
Hasher defines a Hasher struct.
func (Hasher) ByBlake2b ¶ added in v1.1.2
ByBlake2b computes the BLAKE2b hash or hmac of the input data.
func (Hasher) ByBlake2s ¶ added in v1.1.2
ByBlake2s computes the BLAKE2s hash or hmac of the input data.
func (Hasher) ByRipemd160 ¶
ByRipemd160 computes the RIPEMD160 hash or hmac of the input data.
func (Hasher) FromString ¶
FromString encrypts from string.
func (Hasher) ToBase64Bytes ¶
ToBase64Bytes outputs as base64 byte slice.
func (Hasher) ToBase64String ¶
ToBase64String outputs as base64 string.
func (Hasher) ToHexBytes ¶
ToHexBytes outputs as hex byte slice.
func (Hasher) ToRawBytes ¶
ToRawBytes outputs as raw byte slice without encoding.
func (Hasher) ToRawString ¶
ToRawString outputs as raw string without encoding.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package md2 implements the MD2 hash algorithm as defined in RFC 1319.
|
Package md2 implements the MD2 hash algorithm as defined in RFC 1319. |
|
Package sm3 implements the SM3 hash algorithm as defined in GB/T 32918.1-2016.
|
Package sm3 implements the SM3 hash algorithm as defined in GB/T 32918.1-2016. |