3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-12-23 11:12:44 +01:00
ergo/vendor/github.com/GehirnInc/crypt
2020-10-02 16:48:37 -04:00
..
common first draft of atheme migration code 2020-10-02 16:48:37 -04:00
internal first draft of atheme migration code 2020-10-02 16:48:37 -04:00
md5_crypt first draft of atheme migration code 2020-10-02 16:48:37 -04:00
.travis.yml first draft of atheme migration code 2020-10-02 16:48:37 -04:00
AUTHORS.md first draft of atheme migration code 2020-10-02 16:48:37 -04:00
crypt.go first draft of atheme migration code 2020-10-02 16:48:37 -04:00
LICENSE first draft of atheme migration code 2020-10-02 16:48:37 -04:00
README.rst first draft of atheme migration code 2020-10-02 16:48:37 -04:00

image

crypt - A password hashing library for Go

crypt provides pure golang implementations of UNIX's crypt(3).

The goal of crypt is to bring a library of many common and popular password hashing algorithms to Go and to provide a simple and consistent interface to each of them. As every hashing method is implemented in pure Go, this library should be as portable as Go itself.

All hashing methods come with a test suite which verifies their operation against itself as well as the output of other password hashing implementations to ensure compatibility with them.

I hope you find this library to be useful and easy to use!

Install

To install crypt, use the go get command.

go get github.com/GehirnInc/crypt

Usage

package main

import (
    "fmt"

    "github.com/GehirnInc/crypt"
    _ "github.com/GehirnInc/crypt/sha256_crypt"
)

func main() {
    crypt := crypt.SHA256.New()
    ret, _ := crypt.Generate([]byte("secret"), []byte("$5$salt"))
    fmt.Println(ret)

    err := crypt.Verify(ret, []byte("secret"))
    fmt.Println(err)

    // Output:
    // $5$salt$kpa26zwgX83BPSR8d7w93OIXbFt/d3UOTZaAu5vsTM6
    // <nil>
}

Documentation

The documentation is available on GoDoc.