hasher

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2020 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/salifm/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/salifm/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