You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
385 B
20 lines
385 B
package crypto
|
|
|
|
import (
|
|
"crypto/md5"
|
|
"encoding/hex"
|
|
"strings"
|
|
)
|
|
|
|
// Md5Check md5 Check method
|
|
func (c *Crypto) Md5Check(content, encrypted string) bool {
|
|
return strings.EqualFold(c.Md5Encode(content), encrypted)
|
|
}
|
|
|
|
// Md5Encode md5 Signature function
|
|
func (c *Crypto) Md5Encode(data string) string {
|
|
h := md5.New()
|
|
h.Write([]byte(data))
|
|
return hex.EncodeToString(h.Sum(nil))
|
|
}
|