hashutil

package
v0.6.17 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package hashutil provide some util for quickly generate hash

Index

Constants

View Source
const (
	AlgoCRC32  = "crc32"
	AlgoCRC64  = "crc64"
	AlgoMD5    = "md5"
	AlgoSHA1   = "sha1"
	AlgoSHA224 = "sha224"
	AlgoSHA256 = "sha256"
	AlgoSHA384 = "sha384"
	AlgoSHA512 = "sha512"
)

hash algorithm names

Variables

This section is empty.

Functions

func Base32Bytes

func Base32Bytes(algo string, src any) []byte

Base32Bytes generate base32 hash bytes by given algorithm

func Base64Bytes

func Base64Bytes(algo string, src any) []byte

Base64Bytes generate base64 hash bytes by given algorithm

func Hash

func Hash(algo string, src any) string

Hash generate hex hash string by given algorithm

func Hash32

func Hash32(algo string, src any) string

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

func Hash64

func Hash64(algo string, src any) 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 string, src any) []byte

HashSum generate hash sum bytes by given algorithm

func HexBytes

func HexBytes(algo string, src any) []byte

HexBytes generate hex hash bytes by given algorithm

func MD5

func MD5(src any) string

MD5 generate md5 string by given src

func NewHash

func NewHash(algo string) 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 any) 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

This section is empty.

Jump to

Keyboard shortcuts

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