signature.go
510 字节
package signature
import (
"crypto/sha256"
"encoding/hex"
"strings"
)
const (
mixtureBegin string = "v!(MmM"
mixtureEnd string = "MmM)i^"
)
func SignaString(s string) string {
toSign := mixtureBegin + s + mixtureEnd
sha256 := sha256.New()
sha256.Write([]byte(toSign))
signHex := hex.EncodeToString(sha256.Sum(nil))
return signHex
}
func CheckSignaString(s string, compared string) bool {
signHex := SignaString(s)
if strings.Compare(signHex, compared) == 0 {
return true
}
return false
}