• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.gitignoreH A D11-Mar-2020273

LICENSEH A D11-Mar-20201.1 KiB

README.mdH A D11-Mar-20201.4 KiB

argon2.goH A D11-Mar-20203.7 KiB

argon2_test.goH A D11-Mar-20206.6 KiB

bench_test.goH A D11-Mar-20203.7 KiB

context.goH A D11-Mar-20202.5 KiB

error.goH A D11-Mar-20202.6 KiB

example_test.goH A D11-Mar-20201.1 KiB

go.modH A D11-Mar-202049

wrapper.hH A D11-Mar-20201.7 KiB

README.md

1# go-argon2
2
3[![GoDoc](https://godoc.org/github.com/bitmark-inc/go-argon2?status.svg)](https://godoc.org/github.com/bitmark-inc/go-argon2)
4
5Go bindings for the reference C implementation of
6[Argon2](https://github.com/P-H-C/phc-winner-argon2), the winner of the
7[Password Hash Competition](https://password-hashing.net).
8
9## Installation
10
11~~~
12$ go get -d github.com/bitmark-inc/go-argon2
13~~~
14
15This package depends on `libargon2`, specifically `libargon2.so` and
16`argon2.h`.  Make sure the library files are available in `/usr` or
17`/usr/local` depending on your OS.  Check that pkg-config can detect
18the installed library.
19
20~~~
21Debian-like: apt install libargon2-dev
22FreeBSD:     pkg install libargon2
23
24all: pkgconfig --cflags --libs libargon2
25~~~
26
27Test the Go library
28
29~~~
30$ git clone https://github.com/bitmark-inc/go-argon2.git
31$ cd go-argon2
32$ go test -v ./...
33
34
35## Usage
36### Raw hash with default configuration
37
38~~~go
39hash, err := argon2.Hash(argon2.NewContext(), []byte("password"), []byte("somesalt"))
40if err != nil {
41	log.Fatal(err)
42}
43
44fmt.Printf("%x\n", hash)
45~~~
46
47### Encoded hash with custom configuration
48
49~~~go
50ctx := &argon2.Context{
51	Iterations:  5,
52	Memory:      1 << 16,
53	Parallelism: 2,
54	HashLen:     32,
55	Mode:        argon2.ModeArgon2i,
56	Version:     argon2.Version13,
57}
58
59s, err := argon2.HashEncoded(ctx, []byte("password"), []byte("somesalt"))
60
61if err != nil {
62	log.Fatal(err)
63}
64fmt.Println(s)
65~~~
66