argon2

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2022 License: MIT Imports: 7 Imported by: 0

README

Argon2

A dead simple utility for hashing and validating argon2 passwords.

This is just a wrapper around the standard go argon2 package.

Usage

password := "hello world"

hashed, _ := HashPassword(password, &Params{
    Variant:     Variant2I,
    SaltLen:     16,
    Memory:      32 * 1024,
    Time:        2,
    Parallelism: 2,
    KeyLen:      32,
})

valid, _ := ValidatePassword("hello world", hashed)

Installation

go get gitlab.com/projet-iota/go/argon2

License

This project is licensed under the terms of the MIT license.

Documentation

Overview

Package argon2 contains methods to hash and validate a password

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashPassword

func HashPassword(password string, params *Params) (string, error)

HashPassword generates a pwd hash using specified parameters

The params object is updated in place so this method is not thread safe if the params are reused

func ValidatePassword

func ValidatePassword(password string, encoded string) (valid bool, err error)

ValidatePassword validates that a password matches the encoded version

Types

type Params

type Params struct {
	Variant     Variant
	SaltLen     uint32
	Memory      uint32
	Time        uint32
	Parallelism uint8
	KeyLen      uint32
	// contains filtered or unexported fields
}

Params has all the params

type Variant

type Variant string

Variant is the argon2 variant

const (
	Variant2ID Variant = "argon2id"
	Variant2I  Variant = "argon2i"
)

Possible values for variants

Jump to

Keyboard shortcuts

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