README ¶
Installation: goinstall github.com/jameskeane/bcrypt Example use: package main import ( "fmt" "github.com/jameskeane/bcrypt" ) var password = "WyWihatdyd?frub1" var bad_password = "just a wild guess" func main() { // generate a random salt with default rounds of complexity salt, _ := bcrypt.Salt() // generate a random salt with 10 rounds of complexity salt, _ = bcrypt.Salt(10) // hash and verify a password with random salt hash, _ := bcrypt.Hash(password) if bcrypt.Match(password, hash) { fmt.Println("They match") } // hash and verify a password with a static salt hash, _ = bcrypt.Hash(password, salt) if bcrypt.Match(password, hash) { fmt.Println("They match") } // verify a random password fails to match the hashed password if !bcrypt.Match(bad_password, hash) { fmt.Println("They don't match") } } Todo: grep 'TODO' * -r Notes: * This library is derived from jBcrypt by Damien Miller <djm@mindrot.org> * bcrypt_test.go is from ZooWar.com
Documentation ¶
Index ¶
- Constants
- Variables
- func Hash(password string, salt ...string) (ps string, err error)
- func HashBytes(password []byte, salt ...[]byte) (hash []byte, err error)
- func Match(password, hash string) bool
- func MatchBytes(password []byte, hash []byte) bool
- func Salt(rounds ...int) (string, error)
- func SaltBytes(rounds ...int) (salt []byte, err error)
Constants ¶
View Source
const ( MaxRounds = 31 MinRounds = 4 DefaultRounds = 12 SaltLen = 16 BlowfishRounds = 16 )
Variables ¶
View Source
var ( InvalidRounds = errors.New("bcrypt: Invalid rounds parameter") InvalidSalt = errors.New("bcrypt: Invalid salt supplied") )
Functions ¶
func MatchBytes ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.