hasher

package module
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2021 License: MIT Imports: 4 Imported by: 0

README

hasher

Library for easy hashing and verifying passwords.

The hashing algorithm is Argon2id.

The parameters are:

  • Memory: 64 MiB
  • Iterations: 1
  • Parallelism: 4
  • Salt length: 32

The result is:

  • Hash: base64 string with length of 43
  • Salt: base64 string with length of 43

Usage

Import
import (
    "github.com/salif/hasher"
)
Hash
password := "password"
hash, salt, err := hasher.Hash(password)
// save hash and salt to database if err is nil
Verify
password := "password"
// get hash and salt from database
match, err := hasher.Verify(password, hash, salt)
if err == nil && match {
    // The password is correct
}

CLI tool

Install
go get github.com/salif/hasher/cmd/hasher
Hash
hasher "password"
or
echo -n "password" | hasher
Verify
hasher "password" "hash" "salt"
or
echo -n "password" | hasher "hash" "salt"

License

This library is licensed under the MIT license

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Hash

func Hash(password string) (string, string, error)

func Verify

func Verify(password string, hash string, salt string) (bool, error)

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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