raw

package
v1.0.11 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2021 License: BSD-3-Clause Imports: 7 Imported by: 5

Documentation

Overview

Package raw provides a raw implementation of the sha256-crypt and sha512-crypt primitives.

Index

Constants

View Source
const DefaultRounds = 5000

This is the 'default' number of rounds for sha256-crypt and sha512-crypt. If this rounds value is used the number of rounds is not explicitly specified in the modular crypt format, as it is the default.

View Source
const MaximumRounds = 999999999

The maximum number of rounds permissible for sha256-crypt and sha512-crypt. Don't use this!

View Source
const MinimumRounds = 1000

The minimum number of rounds permissible for sha256-crypt and sha512-crypt.

View Source
const RecommendedRounds = 10000

This is the recommended number of rounds for sha256-crypt and sha512-crypt. This may change with subsequent releases of this package. It is recommended that you invoke sha256-crypt or sha512-crypt with this value, or a value proportional to it.

Variables

View Source
var ErrInvalidRounds = fmt.Errorf("invalid number of rounds")

Indicates that the number of rounds specified is not in the valid range.

View Source
var ErrInvalidStub = fmt.Errorf("invalid stub")

Indicates that a password hash or stub is invalid.

Functions

func Crypt256

func Crypt256(password, salt string, rounds int) string

Calculates sha256-crypt. The password must be in plaintext and be a UTF-8 string.

The salt must be a valid ASCII between 0 and 16 characters in length inclusive.

See the constants in this package for suggested values for rounds.

Rounds must be in the range 1000 <= rounds <= 999999999. The function panics if this is not the case.

The output is in modular crypt format.

func Crypt512

func Crypt512(password, salt string, rounds int) string

Calculates sha256-crypt. The password must be in plaintext and be a UTF-8 string.

The salt must be a valid ASCII between 0 and 16 characters in length inclusive.

See the constants in this package for suggested values for rounds.

Rounds must be in the range 1000 <= rounds <= 999999999. The function panics if this is not the case.

The output is in modular crypt format.

func EncodeBase64

func EncodeBase64(b []byte) string

Encodes a byte string using the sha2-crypt base64 variant.

func Parse

func Parse(stub string) (isSHA512 bool, salt, hash string, rounds int, err error)

Scans a sha256-crypt or sha512-crypt modular crypt stub or modular crypt hash to determine configuration parameters.

Types

This section is empty.

Jump to

Keyboard shortcuts

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