hasher

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: May 9, 2023 License: MPL-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package hasher provides common functions for working with passwords.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPasswordHash

func CheckPasswordHash(password, hash string) bool

CheckPasswordHash compares a plaintext password with it's possible bcrypt hash equivalent.

Example
fmt.Println(CheckPasswordHash("super-secret-password", "$2a$04$09IzQ3oawFacAKHjG7QFneYFIaxV2fCNy7RG63RlFKQd.1ChHU6Xa"))
fmt.Println(CheckPasswordHash("super-secret-password", "not-a-hash"))
Output:

true
false

func HashPassword

func HashPassword(password string) (string, error)

HashPassword returns the bcrypt hash of the password at the minimum cost.

Example
hashed, _ := HashPassword("super")
fmt.Println(hashed)
Output:

Types

This section is empty.

Jump to

Keyboard shortcuts

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