mirror of
https://github.com/eiblog/eiblog.git
synced 2026-02-04 13:52:26 +08:00
27 lines
410 B
Go
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)
|
|
}
|