sha1

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 sha1 implements a Django compatible SHA1 algorithm.

Index

Constants

This section is empty.

Variables

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

Errors returned by SHA1PasswordHasher.

Functions

This section is empty.

Types

type SHA1PasswordHasher

type SHA1PasswordHasher struct {
	// Algorithm identifier.
	Algorithm string
	// Use salt to encode.
	Salted bool
}

SHA1PasswordHasher implements Salted SHA1 password hasher.

func NewSHA1PasswordHasher

func NewSHA1PasswordHasher() *SHA1PasswordHasher

NewSHA1PasswordHasher secures password hashing using Salted SHA1 algorithm (not recommended).

func NewUnsaltedSHA1PasswordHasher

func NewUnsaltedSHA1PasswordHasher() *SHA1PasswordHasher

NewUnsaltedSHA1PasswordHasher is an incredibly insecure algorithm that should never be used. It stores unsalted SHA1 hashes with an empty salt.

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

func (*SHA1PasswordHasher) Encode

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

Encode turns a plain-text password into a hash.

func (*SHA1PasswordHasher) Verify

func (h *SHA1PasswordHasher) 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