Documentation
¶
Index ¶
- Variables
- func Generate(plaintext string, nanoTime int64, salting ...SaltingFunc) (r string)
- func GenerateWithAlg(plaintext string, nanoTime int64, alg Hash, salting ...SaltingFunc) (r string)
- func Verify(plaintext string, encodedPassword string, nanoTime int64, ...) (r bool)
- func VerifyWithAlg(plaintext string, encodedPassword string, nanoTime int64, alg Verifier, ...) (r bool)
- type Hash
- type SaltingFunc
- type Verifier
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 ¶
Types ¶
Click to show internal directories.
Click to hide internal directories.