passwordv2

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encode

func Encode(rawPwd string, options *Options) (string, string)

Encode takes two arguments, a raw password, and a pointer to an Options struct. In order to use default options, pass `nil` as the second argument. It returns the generated salt and encoded key for the user.

func Verify

func Verify(rawPwd string, salt string, encodedPwd string, options *Options) bool

Verify takes four arguments, the raw password, its generated salt, the encoded password, and a pointer to the Options struct, and returns a boolean value determining whether the password is the correct one or not. Passing `nil` as the last argument resorts to default options.

Types

type Options

type Options struct {
	SaltLen      int
	Iterations   int
	KeyLen       int
	HashFunction func() hash.Hash
}

Options is a struct for custom values of salt length, number of iterations, the encoded key's length, and the hash function being used. If set to `nil`, default options are used: &Options{ 256, 10000, 512, "sha512" }

Jump to

Keyboard shortcuts

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