Categorygithub.com/intermernet/pw
modulepackage
0.3.5
Repository: https://github.com/intermernet/pw.git
Documentation: pkg.go.dev

# README

PkgGoDev Build Status Coverage Status

pw is a Go library for password authentication

It attempts to put into practice the methodology described in CrackStation's "Salted Password Hashing - Doing it Right".

It uses scrypt for key derivation, and assumes the use of an HMAC key for extra security.

The HMAC Key should be provided from somewhere outside of the database which stores the user IDs, hashes and salts. It should, at least, be stored in a secure file on the server, but it's recommended to use an external server, or service, to provide the HMAC key.

The generated hashes are 256 bits in length, as are any generated salts.

The input HMAC key and password are only limited in length by the underlying Go crypto libraries.

Documentation available at https://pkg.go.dev/github.com/intermernet/pw

See the Go playground for a usage example.

# Functions

New returns a new ID.

# Constants

KeyLen (key length and salt length) is 32 bytes (256 bits).
N is a CPU/memory cost parameter.
P must satisfy R * P < 2³⁰.
R must satisfy R * P < 2³⁰.

# Structs

ID contains the HMAC, the password, the salt and the hash to check.