28 lines
430 B
Go
28 lines
430 B
Go
package mycrypto
|
|
|
|
import (
|
|
"crypto/md5"
|
|
"crypto/sha1"
|
|
"crypto/sha256"
|
|
"encoding/hex"
|
|
)
|
|
|
|
func Md5(str string) string {
|
|
h := md5.New()
|
|
h.Write([]byte(str))
|
|
|
|
return hex.EncodeToString(h.Sum(nil))
|
|
}
|
|
|
|
func Sha1(str string) string {
|
|
h := sha1.New()
|
|
h.Write([]byte(str))
|
|
return hex.EncodeToString(h.Sum(nil))
|
|
}
|
|
|
|
func Sha256(str string) string {
|
|
h := sha256.New()
|
|
h.Write([]byte(str))
|
|
return hex.EncodeToString(h.Sum(nil))
|
|
}
|