md5

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2020 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package md5 implements a Django compatible MD5 algorithm.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrHashComponentMismatch  = errors.New("unchained/md5: hashed password components mismatch")
	ErrAlgorithmMismatch      = errors.New("unchained/md5: algorithm mismatch")
	ErrSaltContainsDollarSing = errors.New("unchained/md5: salt contains dollar sign ($)")
	ErrSaltIsEmpty            = errors.New("unchained/md5: salt is empty")
)

Errors returned by UnsaltedMD5PasswordHasher and/or MD5PasswordHasher.

Functions

This section is empty.

Types

type MD5PasswordHasher

type MD5PasswordHasher struct {
	// Algorithm identifier.
	Algorithm string
}

MD5PasswordHasher implements Salted MD5 password hasher.

func NewMD5PasswordHasher

func NewMD5PasswordHasher() *MD5PasswordHasher

NewMD5PasswordHasher secures password hashing using Salted MD5 algorithm (not recommended).

func (*MD5PasswordHasher) Encode

func (h *MD5PasswordHasher) Encode(password string, salt string) (string, error)

Encode turns a plain-text password into a hash.

func (*MD5PasswordHasher) Verify

func (h *MD5PasswordHasher) Verify(password string, encoded string) (bool, error)

Verify if a plain-text password matches the encoded digest.

type UnsaltedMD5PasswordHasher

type UnsaltedMD5PasswordHasher struct {
	// Algorithm identifier.
	Algorithm string
}

UnsaltedMD5PasswordHasher implements a simple MD5 password hasher.

func NewUnsaltedMD5PasswordHasher

func NewUnsaltedMD5PasswordHasher() *UnsaltedMD5PasswordHasher

NewUnsaltedMD5PasswordHasher is an incredibly insecure algorithm that should never be used. It stores unsalted MD5 hashes without the algorithm prefix, also hashes with an empty salt.

This algorithm is implemented because Django used to store passwords this way and to accept such password hashes.

func (*UnsaltedMD5PasswordHasher) Encode

func (h *UnsaltedMD5PasswordHasher) Encode(password string) (string, error)

Encode turns a plain-text password into a hash.

func (*UnsaltedMD5PasswordHasher) Verify

func (h *UnsaltedMD5PasswordHasher) Verify(password string, encoded string) (bool, error)

Verify if a plain-text password matches the encoded digest.

Jump to

Keyboard shortcuts

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