pbkdf2 – github.com/xdg-go/pbkdf2 Index | Files

package pbkdf2

import "github.com/xdg-go/pbkdf2"

Package pbkdf2 implements password-based key derivation using the PBKDF2 algorithm described in RFC 2898 and RFC 8018.

It provides a drop-in replacement for `golang.org/x/crypto/pbkdf2`, with the following benefits:

- Released as a module with semantic versioning

- Does not pull in dependencies for unrelated `x/crypto/*` packages

- Supports Go 1.9+

See https://tools.ietf.org/html/rfc8018#section-4 for security considerations in the selection of a salt and iteration count.

Index

Functions

func Key

func Key(password, salt []byte, iterCount, keyLen int, h func() hash.Hash) []byte

Key generates a derived key from a password using the PBKDF2 algorithm. The inputs include salt bytes, the iteration count, desired key length, and a constructor for a hashing function. For example, for a 32-byte key using SHA-256:

key := Key([]byte("trustNo1"), salt, 10000, 32, sha256.New)

Source Files

pbkdf2.go

Version
v1.0.0 (latest)
Published
Mar 28, 2021
Platform
linux/amd64
Imports
3 packages
Last checked
11 months ago

Tools for package owners.