idkey

package module
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: MIT Imports: 7 Imported by: 0

README

idkey PkgGoDev

Golang Argon2id 密码hash和验证

安装方法

go get -u github.com/xiaoqidun/idkey

使用方法

// 生成argon2id hash密码
hash := idkey.Encode([]byte("admin"), nil)
// 进行argon2id hash验证
verify := idkey.Verify([]byte("admin"), hash)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encode

func Encode(password []byte, options *EncodeOptions) string

Encode 将密码编码成密文

func Verify

func Verify(password []byte, passwordHash string) bool

Verify 验证密码编码后是否等于密文

Types

type Data

type Data struct {
	EncodeOptions        // 加密选项
	Hash          []byte // 密码密文
	Salt          []byte // 加密盐值
}

Data 密文编码结构

func Decode

func Decode(passwordHash string) (data *Data, err error)

Decode 获取密文编码结构

type EncodeOptions

type EncodeOptions struct {
	Time    uint32 // 时间参数
	Memory  uint32 // 内存参数
	Threads uint8  // 线程参数
	KeyLen  uint32 // 密文长度
}

EncodeOptions 密文编码选项

Jump to

Keyboard shortcuts

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