forked from coreos/core-admin
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhash.go
More file actions
30 lines (25 loc) · 668 Bytes
/
hash.go
File metadata and controls
30 lines (25 loc) · 668 Bytes
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
package main
import (
"fmt"
"code.google.com/p/go.crypto/bcrypt"
)
var cmdHash = &Command{
UsageLine: "hash [password]",
Short: "generate a password hash for inserting into the database",
Long: `
The administrator password is kept in the datastore. To update that password you generate
a bcrypt hash using this command and then manually put it into the datastore.
`,
}
func init() {
cmdHash.Run = runHash // break init loop
}
func runHash(cmd *Command, args []string) {
if len(args) != 1 {
fmt.Println("ERROR: password argument expected")
return
}
hash, _ := bcrypt.GenerateFromPassword([]byte(args[0]), 10)
fmt.Println(string(hash))
return
}