hashers

package module
v0.0.0-...-5e5d6af Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 31, 2017 License: GPL-3.0 Imports: 16 Imported by: 3

README

Go Django Hashers GoDoc Go Report Card

Go implementation of password hashers used in Django

Implemented hashers:

  • pbkdf2_sha256
  • pbkdf2_sha1
  • sha1
  • md5
  • unsalted_sha1
  • unsalted_md5

Unsalted hashers are not allowed by hashers.MakePassword function. You can use them just with hashers.CheckPassword.

Hashers based on bcrypt are not implemented because golang.org/x/crypto/bcrypt is not yet compatible with Python's bcrypt.

By default hashers.MakePassword is using pbkdf2_sha256 hasher. If you really want to change it (i.e. when you want to have passwords compatible with Django 1.3 or older), you can set hashers.DefaultHasher variable to one of supported hashers:

hashers.DefaultHasher = "sha1"

Installation

go get -u github.com/meehow/go-django-hashers

Usage

Usage is quite straightforward and simple.

Check example files:

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Iter is a number of iterations used to make pbkdf2 passwords.
	// 20000 is't a default value used in Django.
	Iter = 20000
	// SaltSize is a size of salt used to make passwords.
	// 12 is default size used in Django.
	SaltSize = 12
	// DefaultHasher is a default hashing algorithm.
	// pbkdf2_sha256 is used by default in Django
	DefaultHasher = "pbkdf2_sha256"
)

Functions

func CheckPassword

func CheckPassword(password, encoded string) (bool, error)

CheckPassword checks if given password is matching given hash

func MakePassword

func MakePassword(password string) (string, error)

MakePassword generates new password using algorithm set in DefaultHasher

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL