hash

package
v0.0.0-...-3de62b2 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2020 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareHash

func CompareHash(hash, pass string) bool

CompareHash compares a password and the salt with the hash. return if the password is a match for the hash

Example
pass := "pass"
hash, err := Hash(pass)
if err != nil {
	// Use a better handler
	panic(err)
}
fmt.Println(hash)

CompareHash(hash, pass)       // true
CompareHash(hash, "not pass") // false
Output:

func GenerateKey

func GenerateKey(n int) string

GenerateKey generate a n th long key

Example
fmt.Println(GenerateKey(10))
Output:

&[l8+P$w\B

func Hash

func Hash(pass string) (string, error)

Hash hashes the password with the salt and return the hash as a string by using the bcrypt algorithm.

Example
pass := "pass"
hash, err := Hash(pass)
if err != nil {
	// Use a better handler
	panic(err)
}
fmt.Println(hash)

CompareHash(hash, pass)       // true
CompareHash(hash, "not pass") // false
Output:

Types

This section is empty.

Jump to

Keyboard shortcuts

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