hasher

package module
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2021 License: MIT Imports: 6 Imported by: 0

README

hasher

Library and cli tool for password hashing

The hashing algorithm is Argon2id.

The result is:

  • Hash: hexadecimal string with length of 64
  • Salt: hexadecimal string with length of 32
  • Version: int

Usage

Get
go get -u salif.eu/go/hasher
Import
import (
    "salif.eu/go/hasher"
)
Hash
var password = "password"
var hash, salt, version = hasher.Hash(password)
// save hash, salt and version to database
Verify
var password = "password"
// get hash, salt and version from database
var ok = hasher.Verify(password, hash, salt, version)
if ok {
    // The password is correct
}

CLI tool

Install
go get -u salif.eu/go/hasher/cmd/hasher
Hash
echo -n "password" | hasher
or
hasher "filename"
Verify
echo -n "password" | hasher "hash" "salt" 2
or
hasher "filename" "hash" "salt" 2

License

This library is licensed under the MIT license

Documentation

Index

Constants

View Source
const VERSION = 2

Variables

This section is empty.

Functions

func Hash

func Hash(password string) (string, string, int)

func NeedsRehash

func NeedsRehash(version int) bool

func Verify

func Verify(password string, hash string, salt string, version int) bool

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