scrypt

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithN

func WithN(N int) types.Option

WithN configure the N value for Encoder, default value is 32768

func WithP

func WithP(P int) types.Option

WithP configure the P value for Encoder, default value is 8

func WithR

func WithR(R int) types.Option

WithR configure the R value for Encoder, default value is 8

func WithSalt

func WithSalt(salt []byte) types.Option

WithSalt configure the salt value for Encoder, default automatically generate random strings

func WithSaltLen

func WithSaltLen(len int) types.Option

WithSaltLen configure the salt length for Encoder, default value is 16

Types

type Encoder

type Encoder struct {
	SaltLen int // bytes to use as salt (octets)

	N int // CPU/memory cost parameter (logN)
	R int // block size parameter (octets)
	P int // parallelisation parameter (positive int)
	// contains filtered or unexported fields
}

func (*Encoder) Encode

func (e *Encoder) Encode(src string) (string, error)

Encode returns the hash value of the given data

func (*Encoder) GetSalt

func (e *Encoder) GetSalt() ([]byte, error)

GetSalt Returns the salt if present, otherwise nil

func (*Encoder) Hash added in v1.2.2

func (e *Encoder) Hash(src string) ([]byte, error)

Hash Generate and return a hash value in []byte format

func (*Encoder) Verify

func (e *Encoder) Verify(hash, rawData string) (bool, error)

Verify compares a encoded data with its possible plaintext equivalent

Jump to

Keyboard shortcuts

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