encrypt

package
v0.0.0-...-dc62a57 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SHA1      = "sha1"
	SHA256    = "sha256"
	SHA512    = "sha512"
	SHA3_256  = "sha3-256"
	SHA3_512  = "sha3-512"
	MD5       = "md5"
	Murmur32  = "murmur32"
	Murmur64  = "murmur64"
	Murmur128 = "murmur128"
)

Variables

View Source
var (
	ErrUndefinedHashFunc = errors.New("未定义的HashFunc")
)

Functions

func Encrypt

func Encrypt(raw string) string

func EncryptWithHash

func EncryptWithHash(raw, hashAlgo string) string

func EncryptWithOption

func EncryptWithOption(raw string, opt *EncryptOption) string

func HashWithDefault

func HashWithDefault(data []byte, hashKey string) []byte

func NewHashFunc

func NewHashFunc(algorithm string) (hash.Hash, error)

func NewHashFuncForPBKDF2

func NewHashFuncForPBKDF2(algorithm string) (func() hash.Hash, error)

func NewHashFuncForPBKDF2WithDefault

func NewHashFuncForPBKDF2WithDefault(algorithm string) (func() hash.Hash, string)

func NewHashFuncWithDefault

func NewHashFuncWithDefault(algorithm string) (hash.Hash, string)

func Verify

func Verify(raw, encrypted string) bool

func VerifyHashWithDefault

func VerifyHashWithDefault(row []byte, enp []byte, hashKey string) bool

func VerifyWithError

func VerifyWithError(raw, encrypted string) (string, bool)

Types

type EncryptOption

type EncryptOption struct {
	SaltLen      int
	Iterations   int
	KeyLen       int
	HashFunction func() hash.Hash
}

type Hasher

type Hasher struct {
	// contains filtered or unexported fields
}

func NewHasher

func NewHasher(hf hash.Hash, salt []byte) *Hasher

func (*Hasher) Hash

func (h *Hasher) Hash(data []byte) []byte

func (*Hasher) Verify

func (h *Hasher) Verify(data, exp []byte) bool

Jump to

Keyboard shortcuts

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