hasher

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 18, 2023 License: MPL-2.0 Imports: 1 Imported by: 0

README

Module contains hasher package

hasher package

To use hasher package just import it as:

import "github.com/kyrylolytvynovskyi/lets-go-chat/pkg/hasher"

Documentation

Overview

Package hasher provide functions for coverting given plain-text password into a hash and validating plain-text password against given hash

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPasswordHash

func CheckPasswordHash(password, hash string) bool

Receives string password and hash and returns true if hashed password is equal to provided hash

Example
myPassword := "myPassword"
fmt.Println(CheckPasswordHash(myPassword, "$2a$14$fo41Lff9uGg3Bmm6OZ1g9uZGsZALyX.8GGwG/Gd0zmngNBM.4RKbG"))
fmt.Println(CheckPasswordHash(myPassword, "wrong_hash"))
Output:

true
false

func HashPassword

func HashPassword(password string) (string, error)

Receives string password as input and returns its string hash or error if any problems occur

Example
myPassword := "myPassword"
hash, _ := HashPassword(myPassword)
fmt.Println(myPassword)
fmt.Println(hash)
Output:

myPassword
$2a$14$fo41Lff9uGg3Bmm6OZ1g9uZGsZALyX.8GGwG/Gd0zmngNBM.4RKbG

Types

This section is empty.

Jump to

Keyboard shortcuts

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