hashlib

package
v1.0.18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base32Bytes

func Base32Bytes(algo HashType, src []byte) []byte

Base32Bytes generate base32 hash bytes by given algorithm

func Base64Bytes

func Base64Bytes(algo HashType, src []byte) []byte

Base64Bytes generate base64 hash bytes by given algorithm

func FileHash

func FileHash(algo HashType, f io.Reader) (string, error)

FileHash Generate a 64-bit md5 bytes from a file or file-like io

func Hash

func Hash(algo HashType, src []byte) string

Hash generate hex hash string by given algorithm

func Hash32

func Hash32(algo HashType, src []byte) string

Hash32 generate hash by given algorithm, then use base32 encode.

func Hash64

func Hash64(algo HashType, src []byte) string

Hash64 generate hash by given algorithm, then use base64 encode.

func HashPasswd

func HashPasswd(pwd, key string) string

HashPasswd for quick hash an input password string, use sha256.

func HashSum

func HashSum(algo HashType, src []byte) []byte

HashSum generate hash sum bytes by given algorithm

func HashSumReader

func HashSumReader(algo HashType, src io.Reader) ([]byte, error)

HashSumReader generate file or file-like hash sum bytes by given algorithm

func HexBytes

func HexBytes(algo HashType, src []byte) []byte

HexBytes generate hex hash bytes by given algorithm

func MD5

func MD5(src []byte) string

MD5 generate md5 string by given src

func NewHash

func NewHash(algo HashType) hash.Hash

NewHash create hash.Hash instance

algo: crc32, crc64, md5, sha1, sha224, sha256, sha384, sha512, sha512_224, sha512_256

func ShortMD5

func ShortMD5(src []byte) string

ShortMD5 Generate a 16-bit md5 bytes. remove first 8 and last 8 bytes from 32-bit md5.

func VerifyPasswd

func VerifyPasswd(wantPwd, pwd, key string) bool

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"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL