Go bindings for the reference C implementation of Argon2, the winner of the Password Hash Competition.
$ 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 tags/20171227 # switch to latest release
$ sudo make install
Test everything is installed correctly:
$ cd $GOPATH/src/github.com/tvdburgt/go-argon2/
$ go test
hash, err := argon2.Hash(argon2.NewContext(), []byte("password"), []byte("somesalt"))
if err != nil {
log.Fatal(err)
}
fmt.Printf("%x\n", hash)
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)