remove ginext/mongoext (no-dep lib)
This commit is contained in:
22
cryptext/hash.go
Normal file
22
cryptext/hash.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package cryptext
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func StrSha256(v string) string {
|
||||
h := sha256.New()
|
||||
h.Write([]byte(v))
|
||||
bs := h.Sum(nil)
|
||||
sh := fmt.Sprintf("%x", bs)
|
||||
return sh
|
||||
}
|
||||
|
||||
func BytesSha256(v []byte) string {
|
||||
h := sha256.New()
|
||||
h.Write(v)
|
||||
bs := h.Sum(nil)
|
||||
sh := fmt.Sprintf("%x", bs)
|
||||
return sh
|
||||
}
|
Reference in New Issue
Block a user