first commit
This commit is contained in:
23
common/tool/encryption.go
Normal file
23
common/tool/encryption.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package tool
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"fmt"
|
||||
"io"
|
||||
)
|
||||
|
||||
/** 加密方式 **/
|
||||
|
||||
func Md5ByString(str string) string {
|
||||
m := md5.New()
|
||||
_, err := io.WriteString(m, str)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
arr := m.Sum(nil)
|
||||
return fmt.Sprintf("%x", arr)
|
||||
}
|
||||
|
||||
func Md5ByBytes(b []byte) string {
|
||||
return fmt.Sprintf("%x", md5.Sum(b))
|
||||
}
|
||||
Reference in New Issue
Block a user