argonauts

package module
v0.0.0-...-697ee46 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2020 License: MIT Imports: 5 Imported by: 0

README

Go Argonauts

Argonauts is a Go library that implements argo2 password hash.

Getting Started

Just a quick example how to use the library:

main.go
package main

import (
	"fmt"

	"github.com/jattschneider/argonauts"
)

func main() {
	// Generate salt
	salt, err := argonauts.Salt()
	if err != nil {
		panic(err)
	}

	// Can can be saved as string and read back with	
	// salt, err := argonauts.ReadString(saltString)
	//
	saltString := argonauts.Sprint(salt)
	fmt.Println(saltString)

	// Generate password hash
	opts := argonauts.DefaultOptions(salt)
	passwd := "somerandompassword"
	hash := argonauts.Hash(opts, []byte(passwd))

	// Also can be saved as string
	hashString := argonauts.Sprint(hash)
	fmt.Println(hashString)

	// Then it can be read back to a byte array
	h, err := argonauts.ReadString(hashString)
	if err != nil {
		panic(err)
	}

	// Compare clear password with the password hash
	if match, err := argonauts.Compare(opts, []byte(passwd), h); err == nil && match {
		fmt.Println("password match!")
	}
}

$ go run main.go
Installing
go get -v github.com/jattschneider/argonauts

Built With

  • Go - The Go Programming Language

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare

func Compare(opts *Options, password, hash []byte) (bool, error)

func EncodeToString

func EncodeToString(hash []byte) string

func Hash

func Hash(opts *Options, password []byte) []byte

func InnerString

func InnerString(s string) string

func ReadString

func ReadString(s string) ([]byte, error)

func Salt

func Salt() ([]byte, error)

func Sprint

func Sprint(hash []byte) string

Types

type Options

type Options struct {
	// contains filtered or unexported fields
}

func DefaultOptions

func DefaultOptions(salt []byte) *Options

Jump to

Keyboard shortcuts

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