digest

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Digests = map[string]Hash{
	"SM3":    sm3Digest,
	"BCRYPT": bcryptDigest,
	"SHA512": sha512Digest,
}
View Source
var (
	ErrPasswordWrong = errors.New("password not match")
)
View Source
var Verifiers = map[string]Verifier{
	"SM3":    sm3Verify,
	"BCRYPT": bcryptVerify,
	"SHA512": sha512Verify,
}

Functions

func Generate

func Generate(plaintext string, nanoTime int64, salting ...SaltingFunc) (r string)

Generate 创建密文

plaintext 明文

nanoTime 时间戳 time.UnixNano()

salting SaltingFunc 混淆文生成器,最多只会处理一个,如不提供将使用默认算法

func GenerateWithAlg

func GenerateWithAlg(plaintext string, nanoTime int64, alg Hash, salting ...SaltingFunc) (r string)

func Verify

func Verify(plaintext string, encodedPassword string, nanoTime int64, salting ...SaltingFunc) (r bool)

func VerifyWithAlg

func VerifyWithAlg(plaintext string, encodedPassword string, nanoTime int64, alg Verifier, salting ...SaltingFunc) (r bool)

Types

type Hash

type Hash func(plain []byte) (digest []byte, err error)

Hash checksum计算器

自行实现或在 Digests 列表中选择

type SaltingFunc

type SaltingFunc func(plaintext string) string

SaltingFunc 混淆器

plaintext 明文

type Verifier

type Verifier func(encoded, plain []byte) (err error)

Jump to

Keyboard shortcuts

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