sha512_crypt

package
v0.0.0-...-6cfb270 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2023 License: BSD-2-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package sha512_crypt implements Ulrich Drepper's SHA512-Crypt password hashing algorithm.

The specification for this algorithm can be found here: http://www.akkadia.org/drepper/SHA-crypt.txt

Index

Constants

View Source
const (
	MagicPrefix   = "$6$"
	RandomSalt    = ""
	RoundsDefault = 5000
	RoundsMax     = 999999999
	RoundsMin     = 1000
	SaltLenMax    = 16
	SaltLenMin    = 1
)

Variables

This section is empty.

Functions

func Crypt

func Crypt(keystr, saltstr string) string

Crypt takes key and salt strings and performs the SHA512-crypt hashing algorithm on them, returning a full hash string suitable for storage and later password verification.

If the salt string is the value RandomSalt, a randomly-generated salt parameter string will be generated with a length of SaltLenMax and RoundsDefault number of rounds.

func GenerateSalt

func GenerateSalt(length, rounds int) string

GenerateSalt creates a random salt parameter string with the random bytes being of the length provided, and the rounds parameter set as specified.

If the length is greater than SaltLenMax, a string of that length will be returned instead. Similarly, if length is less than SaltLenMin, a string of that length will be returned instead.

If rounds is equal to RoundsDefault, then the 'rounds=' part of the salt parameter string is elided.

func Verify

func Verify(key, hash string) bool

Verify hashes a key using the same salt parameters as the given hash string, and if the results match, it returns true.

Types

This section is empty.

Jump to

Keyboard shortcuts

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