md5_crypt

package
v0.0.0-...-b2a8830 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2016 License: BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package md5_crypt implements the standard Unix MD5-Crypt algorithm created by Poul-Henning Kamp for FreeBSD.

Index

Constants

View Source
const (
	CiscoSaltLen = 4 // Cisco IOS only allows salts of length 4.
	MagicPrefix  = "$1$"
	RandomSalt   = ""
	SaltLenMax   = 8
	SaltLenMin   = 1 // Real minimum is 0, but that isn't useful.

)

Variables

This section is empty.

Functions

func Crypt

func Crypt(keystr, saltstr string) string

Crypt takes key and salt strings and performs the MD5-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 of length SaltLenMax.

func GenerateSalt

func GenerateSalt(length int) string

Generate a random salt parameter string of a given length.

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.

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