Skip to content

pzduniak/go-argon2

 
 

Repository files navigation

go-argon2

GoDoc

Go bindings for the reference C implementation of Argon2, the winner of the Password Hash Competition.

Installation

$ go get -d github.com/tvdburgt/go-argon2

This package depends on libargon2, specifically libargon2.so and argon2.h. Make sure the library files are available in /usr:

$ git clone https://github.com/P-H-C/phc-winner-argon2.git argon2
$ cd argon2
$ git checkout 20161029
$ sudo make install

Test everything is installed correctly:

$ cd $GOCODE/src/github.com/tvdburgt/go-argon2/
$ go test

Usage

Raw hash with default configuration

hash, err := argon2.Hash(argon2.NewContext(), []byte("password"), []byte("somesalt"))
if err != nil {
	log.Fatal(err)
}

fmt.Printf("%x\n", hash)

Encoded hash with custom configuration

ctx := &argon2.Context{
	Iterations:  5,
	Memory:      1 << 16,
	Parallelism: 2,
	HashLen:     32,
	Mode:        argon2.ModeArgon2i,
	Version:     argon2.Version13,
}

s, err := argon2.HashEncoded(ctx, []byte("password"), []byte("somesalt"))
if err != nil {
	log.Fatal(err)
}

fmt.Println(s)

About

Go bindings for Argon2

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 77.0%
  • Go 11.0%
  • C++ 7.2%
  • Makefile 2.2%
  • PowerShell 1.3%
  • Roff 0.7%
  • Shell 0.6%