forked from jameskeane/bcrypt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
46 lines (35 loc) · 1.16 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
Installation:
goinstall github.com/weekendlogic/bcrypt
Example use:
package main
import (
"fmt"
"github.com/weekendlogic/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 <[email protected]>
* bcrypt_test.go is from ZooWar.com