Documentation
¶
Index ¶
- func Base32Bytes(algo HashType, src []byte) []byte
- func Base64Bytes(algo HashType, src []byte) []byte
- func FileHash(algo HashType, f io.Reader) (string, error)
- func Hash(algo HashType, src []byte) string
- func Hash32(algo HashType, src []byte) string
- func Hash64(algo HashType, src []byte) string
- func HashPasswd(pwd, key string) string
- func HashSum(algo HashType, src []byte) []byte
- func HashSumReader(algo HashType, src io.Reader) ([]byte, error)
- func HexBytes(algo HashType, src []byte) []byte
- func MD5(src []byte) string
- func NewHash(algo HashType) hash.Hash
- func ShortMD5(src []byte) string
- func VerifyPasswd(wantPwd, pwd, key string) bool
- type HashType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Base32Bytes ¶
Base32Bytes generate base32 hash bytes by given algorithm
func Base64Bytes ¶
Base64Bytes generate base64 hash bytes by given algorithm
func HashPasswd ¶
HashPasswd for quick hash an input password string, use sha256.
func HashSumReader ¶
HashSumReader generate file or file-like hash sum bytes by given algorithm
func NewHash ¶
NewHash create hash.Hash instance
algo: crc32, crc64, md5, sha1, sha224, sha256, sha384, sha512, sha512_224, sha512_256
func ShortMD5 ¶
ShortMD5 Generate a 16-bit md5 bytes. remove first 8 and last 8 bytes from 32-bit md5.
func VerifyPasswd ¶
VerifyPasswd for quick verify input password is valid
- wantPwd from db or config, generated by EncryptPasswd()
Types ¶
type HashType ¶
type HashType string
HashType hash algorithm names
const ( AlgoCRC32 HashType = "crc32" AlgoCRC64 HashType = "crc64" AlgoMD5 HashType = "md5" AlgoSHA1 HashType = "sha1" AlgoSHA224 HashType = "sha224" AlgoSHA256 HashType = "sha256" AlgoSHA384 HashType = "sha384" AlgoSHA512 HashType = "sha512" AlgoSHA512_224 HashType = "sha512_224" AlgoSHA512_256 HashType = "sha512_256" )
Click to show internal directories.
Click to hide internal directories.