raw

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

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

Index

Constants

View Source
const (
	// Minimum number of rounds allowed for sha256-crypt and sha512-crypt.
	MinimumRounds = 1000
	// Maximum number of rounds allowed for sha256-crypt and sha512-crypt.
	MaximumRounds = 999999999
	// The 'default' number of rounds for sha256-crypt and sha512-crypt.
	// When using this rounds value,
	// the number of rounds is not specified explicitly in
	// the modular crypt format, as it is used by default.
	DefaultRounds = 5000
	// Recommended number of rounds for sha256-crypt and sha512-crypt.
	// It is recommended to call sha256-crypt or
	// sha512-crypt with this or a proportional value.
	RecommendedRounds = 10000
)

Variables

View Source
var (
	ErrInvalidStub   = errors.New("invalid stub")
	ErrInvalidRounds = errors.New("invalid number of rounds")
)

Functions

func Crypt256

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

Calculates sha256-crypt. The password must be plaintext and be a UTF-8 string. Salt must be a valid ASCII between 0 and 16 characters in length inclusive. For suggested values for rounds, see the constants in this package. Rounds must be in the range 1000 <= rounds <= 999999999. Otherwise, the function panics. The output is in modular crypt format.

func Crypt512

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

Calculates sha256-crypt. The password must be plaintext and be a UTF-8 string. Salt must be a valid ASCII between 0 and 16 characters in length inclusive. For suggested values for rounds, see the constants in this package. Rounds must be in the range 1000 <= rounds <= 999999999. Otherwise, the function panics. The output is in modular crypt format.

func EncodeBase64

func EncodeBase64(b []byte) string

Encodes a byte string using the sha2-crypt base64.

func Parse

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

Parse scans a modular sha256-crypt or sha512-crypt or modular cryptohash 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