Categorygithub.com/GehirnInc/crypt
modulepackage
0.0.0-20230320061759-8cc1b52080c5
Repository: https://github.com/gehirninc/crypt.git
Documentation: pkg.go.dev

# README

.. image:: https://travis-ci.org/GehirnInc/crypt.svg?branch=master :target: https://travis-ci.org/GehirnInc/crypt

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.

.. code-block:: sh

go get github.com/GehirnInc/crypt

Usage

.. code-block:: go

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_.

.. _GoDoc: https://godoc.org/github.com/GehirnInc/crypt

# Packages

Package apr1_crypt implements the standard Unix MD5-crypt algorithm created by Poul-Henning Kamp for FreeBSD, and modified by the Apache project.
Package common contains routines used by multiple password hashing algorithms.
Package md5_crypt implements the standard Unix MD5-crypt algorithm created by Poul-Henning Kamp for FreeBSD.
Package sha256_crypt implements Ulrich Drepper's SHA256-crypt password hashing algorithm.
Package sha512_crypt implements Ulrich Drepper's SHA512-crypt password hashing algorithm.

# Functions

IsHashSupported returns true if hashedKey has a supported prefix.
New returns a new crypter.
NewFromHash returns a new Crypter using the prefix in the given hashed key.
RegisterCrypt registers a function that returns a new instance of the given crypt function.

# Constants

import github.com/GehirnInc/crypt/apr1_crypt.
import github.com/GehirnInc/crypt/md5_crypt.
import github.com/GehirnInc/crypt/sha256_crypt.
import github.com/GehirnInc/crypt/sha512_crypt.

# Variables

No description provided by the author

# Interfaces

Crypter is the common interface implemented by all crypt functions.

# Type aliases

Crypt identifies a crypt function that is implemented in another package.