This commit is contained in:
deepzz0
2016-09-29 02:59:27 +08:00
parent 60af472ca7
commit ddf508825c
121 changed files with 711894 additions and 0 deletions

26
helper.go Normal file
View File

@@ -0,0 +1,26 @@
package main
import (
"crypto/sha256"
"fmt"
"io"
)
const (
SUCCESS = iota
FAIL
)
// encrypt password
func EncryptPasswd(name, pass string) string {
salt := "%$@w*)("
h := sha256.New()
io.WriteString(h, name)
io.WriteString(h, salt)
io.WriteString(h, pass)
return fmt.Sprintf("%x", h.Sum(nil))
}
func VerifyPasswd(origin, name, input string) bool {
return origin == EncryptPasswd(name, input)
}