crypto

package
v0.0.0-...-492d98f Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2017 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BCrypt = &bcryptPasswordEncoder{}

Functions

func RegisterPasswordEncoder

func RegisterPasswordEncoder(name string, encoder PasswordEncoder)

RegisterPasswordEncoder makes a PasswordEncoder available by the provided name. If Register is called twice with the same name or if driver is nil, it panics.

Types

type PasswordEncoder

type PasswordEncoder interface {
	Gensalt() (salt string, err error)

	/**
	 * Encode the raw password. Generally, a good encoding algorithm applies a SHA-1 or
	 * greater hash combined with an 8-byte or greater randomly generated salt.
	 */
	Encode(password string, salt ...string) (encodedPassword string, err error)
	/**
	 * Matches verify the encoded password obtained from storage matches the submitted raw
	 * password after it too is encoded. Returns true if the passwords match, false if
	 * they do not. The stored password itself is never decoded.
	 *
	 * @param password the raw password to encode and match
	 * @param salt the encoded password or encodedPassword from storage to compare with
	 * @return true if the raw password, after encoding, matches the encoded password from
	 * storage
	 */
	Matches(password, salt string) (ok bool, err error)
}

PasswordEncoder interface for encoding passwords.

func GetPasswordEncoder

func GetPasswordEncoder(name string) (encoder PasswordEncoder, ok bool)

GetPasswordEncoder returns a register PasswordEncoder

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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