hash

package
v0.17.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2024 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareWith

func CompareWith(plain string, hash string) bool

CompareWith reports whether a plain text matches with hash.

For compatibility purposes, it can compare using both SHA256 and bcrypt algorithms. Hashes starting with "$" are assumed to be a bcrypt hash; otherwise, they are treated as SHA256 hashes.

func Do

func Do(pwd string) (string, error)

Do takes a string and returns its hash.

Types

type Hasher

type Hasher interface {
	Do(plain string) (string, error)            // Hash takes a string and returns its hash.
	CompareWith(plain string, hash string) bool // Compare takes a plaintext password and a hashed password, then checks if they match.
}
var Backend Hasher = &backend{}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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