Files
eiblog/helper.go
deepzz0 ddf508825c init
2016-09-29 02:59:27 +08:00

27 lines
410 B
Go

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)
}