hashedpassword

package module
v0.0.0-...-17589d4 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2016 License: MIT Imports: 1 Imported by: 0

README

hashedpassword

A small Go package for hashed passwords. Provides an alternate API around simple-scrypt.

GoDoc

Usage
package main

import "github.com/jpillora/hashedpassword"

type User struct {
	Password hashedpassword.Pwd //custom string type
}

func main() {
	u := User{}

	//attempt manual set
	u.Password = "1234"
	u.Password.Verify("1234") //false

	//generates rand salt then hashes
	u.Password.Set("helloworld")
	u.Password.Verify("worldhello") //false
	u.Password.Verify("helloworld") //true

	//string value
	u.Password //"16384$8$1$b553a4306779af101a75c3e0b085e0e9$4c05fcd11c56ba1560f1b6094e38383b15b9a7ab0126718f7d44a68ab3d53207"
}

Note This package's API is suited for use with Go structs. For standalone strings, see simple-scrypt or bcrypt.

MIT License

Copyright © 2015 <dev@jpillora.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetParams

func SetParams(params Params)

Set the

Types

type Params

type Params scrypt.Params

type Pwd

type Pwd string

func New

func New(initial string) Pwd

func (*Pwd) Check

func (h *Pwd) Check(attempt string) error

Verify compares the password with the attempt and returns an error

func (*Pwd) Set

func (h *Pwd) Set(password string) error

func (*Pwd) SetWithParams

func (h *Pwd) SetWithParams(password string, params Params) error

func (*Pwd) Verify

func (h *Pwd) Verify(attempt string) bool

Verify compares the password with the attempt and returns a bool

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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