pkcs

package module
v0.0.0-...-4dea563 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

README

Go ReportCard GoDoc

pkcs

Password-Based Cryptography via pbkdf2

Documentation

Overview

Example (Verify)
hasher := new(PBKDF2Hasher)
pwd := "testpwd"
hash := hasher.EncodeDefault(pwd)
ok, _ := hasher.Verify(pwd, hash)
fmt.Printf("%v", ok)
ok, _ = hasher.Verify("wrongPwd", hash)
fmt.Printf("%v", ok)
Output:

truefalse

Index

Examples

Constants

View Source
const (
	Iterations = 120000
	SaltSize   = 12
	Keylen     = 256 / 8
	Hasher     = "pbkdf2_sha256"
)

Variables

View Source
var (
	ErrHasher = errors.New("Invalid hash algorithm")
	ErrFmt    = errors.New("Format can not be parsed")
)

Functions

This section is empty.

Types

type PBKDF2Hasher

type PBKDF2Hasher struct {
}

func (PBKDF2Hasher) Decode

func (p PBKDF2Hasher) Decode(str string) (dict map[string]string, err error)

Decode just splits string by $

func (PBKDF2Hasher) Encode

func (p PBKDF2Hasher) Encode(pwd, salt string, iterations int) string

Encode as defined in RFC 2898

func (PBKDF2Hasher) EncodeDefault

func (p PBKDF2Hasher) EncodeDefault(pwd string) string

EncodeDefault as defined in RFC 2898 and default args in const

func (PBKDF2Hasher) GenSalt

func (p PBKDF2Hasher) GenSalt(size int) string

GenSalt Generate a cryptographically secure nonce salt in ASCII.

func (*PBKDF2Hasher) Verify

func (p *PBKDF2Hasher) Verify(pwd string, cipher string) (bool, error)

Verify password with ciphertext

Jump to

Keyboard shortcuts

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