password

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package password

@author: xwc1125

Package password

@author: xwc1125

Index

Constants

This section is empty.

Variables

View Source
var (
	BcryptCost = bcrypt.DefaultCost
	Base       = "www.xwc1125.com"
	BaseKeyLen = 16
)

Functions

func CheckPassword

func CheckPassword(hashPwd, plaintextPwd string) bool

CheckPassword 验证密码的正确性

func EncryptKey

func EncryptKey(key Key, auth string) ([]byte, error)

EncryptKey 加密密码

func GeneratePassword

func GeneratePassword(plaintextPwd string) (hash []byte, err error)

GeneratePassword 生成密码 plaintextPwd 明文密码 对密码进行加密,获得密码hash

func GeneratePasswordByScrypt

func GeneratePasswordByScrypt(password string, salt string) (hash string, err error)

GeneratePasswordByScrypt 生成passHash

func GenerateSalt

func GenerateSalt() (salt string, err error)

GenerateSalt 生成盐

func HashCode

func HashCode(key string) int

HashCode 将任何长度的字符串,通过运算,散列成0-15整数

Types

type Key

type Key struct {
	Id         string
	PrivateKey []byte
}

func DecryptKey

func DecryptKey(data []byte, auth string) (*Key, error)

DecryptKey 解密

Jump to

Keyboard shortcuts

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