password

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: Apache-2.0 Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package password hashes and verifies login passwords with bcrypt, keeps a constant-time fallback for stored values that are not bcrypt hashes, and recognises published placeholder passwords.

Where the stored value comes from, what to do about a plain-text one, and any login throttling are the caller's.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Hash

func Hash(password string) (string, error)

Hash bcrypt-hashes password at the default cost.

func IsBcryptHash

func IsBcryptHash(s string) bool

IsBcryptHash reports whether s carries a bcrypt hash prefix.

func IsPlaceholder

func IsPlaceholder(password string) bool

IsPlaceholder reports whether password is a published placeholder, case-insensitively.

func Verify

func Verify(stored, password string) (ok, plain bool)

Verify reports whether password matches stored. A bcrypt hash ("$2a$", "$2b$" or "$2y$") is compared with bcrypt; anything else is a legacy plain value compared in constant time, and plain reports that so the caller can flag it. An empty stored value or password never matches.

Types

This section is empty.

Jump to

Keyboard shortcuts

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