Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tvdburgt/go-argon2
Go bindings for Argon2
https://github.com/tvdburgt/go-argon2
Last synced: 3 months ago
JSON representation
Go bindings for Argon2
- Host: GitHub
- URL: https://github.com/tvdburgt/go-argon2
- Owner: tvdburgt
- License: mit
- Created: 2016-01-10T20:51:20.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-11-09T17:53:42.000Z (about 6 years ago)
- Last Synced: 2024-06-28T20:50:17.351Z (5 months ago)
- Language: Go
- Size: 34.2 KB
- Stars: 135
- Watchers: 8
- Forks: 14
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-argon2
[![GoDoc](https://godoc.org/github.com/tvdburgt/go-argon2?status.svg)](https://godoc.org/github.com/tvdburgt/go-argon2)
Go bindings for the reference C implementation of
[Argon2](https://github.com/P-H-C/phc-winner-argon2), the winner of the
[Password Hash Competition](https://password-hashing.net).## 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 tags/20171227 # switch to latest release
$ sudo make install
```Test everything is installed correctly:
```
$ cd $GOPATH/src/github.com/tvdburgt/go-argon2/
$ go test
```## Usage
### Raw hash with default configuration```go
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
```go
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)
```