mirror of
https://github.com/eiblog/eiblog.git
synced 2026-02-17 03:42:26 +08:00
init
This commit is contained in:
26
helper.go
Normal file
26
helper.go
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user