password

package module
v0.0.0-...-c53a468 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	// Time is the number of iterations
	Time uint32 = 1
	// Memory is the memory usage in KiB
	Memory uint32 = 1024 * 64
	// Threads is the number of threads to calculate the hash
	Threads uint8 = 2
	// SaltLength is the length of the salt
	SaltLength uint32 = 16
	// KeyLength is the length of the hashed key
	KeyLength uint32 = 32
)

argon2id params

Functions

func Generate

func Generate(password []byte, s ...[]byte) ([]byte, error)

Generate generates a new hashed password

Example
hash, err := Generate([]byte("password"), []byte("salt            "))
if err != nil {
	panic(err)
}
fmt.Printf("Hash: %x\n", hash)
Output:

Hash: 73616c7420202020202020202020202056a3984c5b69cbc7819ff6097dc4fb65f154d5509d0c021f6bc8e7c135253eb3

func Verify

func Verify(password, hash []byte) (bool, error)

Verify verifies a password against a hash

Example
hash, _ := hex.DecodeString("73616c7420202020202020202020202056a3984c5b69cbc7819ff6097dc4fb65f154d5509d0c021f6bc8e7c135253eb3")
ok, err := Verify([]byte("password"), hash)
if err != nil {
	panic(err)
}
fmt.Printf("Password verification: %t\n", ok)
Output:

Password verification: true

Types

This section is empty.

Jump to

Keyboard shortcuts

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