hash

package
v1.0.19 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2025 License: MIT Imports: 2 Imported by: 0

README

📦 Package hash

Source Path: pkg/hash

🏷️ Variables

var (
	ErrInvalidCredentials = errors.New("invalid credentials")
)

🧩 Types

HashPassword
type HashPassword interface {
	HashPassword func(password string) (string, error)
	ComparePassword func(hashPassword string, password string) (error)
}
Hashing
type Hashing struct {
}
Methods
ComparePassword

ComparePassword takes a hashed password and a plaintext password and returns an error if the passwords do not match.

Parameters:

  • hashPassword: The hashed password to compare against (string)
  • password: The plaintext password to compare to the hashed password (string)

Returns:

  • error: nil if the passwords match, otherwise an error (error)
func (h Hashing) ComparePassword(hashPassword string, password string) error
HashPassword

HashPassword takes a plaintext password and returns a hashed version of the password. The hashed password is a string that can be safely stored in a database or other secure storage.

Parameters:

  • password: The plaintext password to be hashed (string)

Returns:

  • string: The hashed version of the password (string)
  • error: Any error encountered while hashing the password (error)
func (h Hashing) HashPassword(password string) (string, error)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidCredentials = errors.New("invalid credentials")
)

Functions

This section is empty.

Types

type HashPassword

type HashPassword interface {
	HashPassword(password string) (string, error)
	ComparePassword(hashPassword string, password string) error
}

func NewHashingPassword

func NewHashingPassword() HashPassword

NewHashingPassword initializes a new Hashing instance for hashing and comparing passwords.

Returns:

  • HashPassword: The initialized Hashing instance.

type Hashing

type Hashing struct{}

func (Hashing) ComparePassword

func (h Hashing) ComparePassword(hashPassword string, password string) error

ComparePassword takes a hashed password and a plaintext password and returns an error if the passwords do not match.

Parameters:

  • hashPassword: The hashed password to compare against (string)
  • password: The plaintext password to compare to the hashed password (string)

Returns:

  • error: nil if the passwords match, otherwise an error (error)

func (Hashing) HashPassword

func (h Hashing) HashPassword(password string) (string, error)

HashPassword takes a plaintext password and returns a hashed version of the password. The hashed password is a string that can be safely stored in a database or other secure storage.

Parameters:

  • password: The plaintext password to be hashed (string)

Returns:

  • string: The hashed version of the password (string)
  • error: Any error encountered while hashing the password (error)

Directories

Path Synopsis
Package mock_hash is a generated GoMock package.
Package mock_hash is a generated GoMock package.

Jump to

Keyboard shortcuts

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