mirror of
https://github.com/portainer/portainer.git
synced 2025-07-25 08:19:40 +02:00
feat(libcrypto): move into the Portainer repository EE-5476 (#10230)
This commit is contained in:
parent
9a234204fa
commit
090fa4aeb3
12 changed files with 194 additions and 7 deletions
19
pkg/libcrypto/hash.go
Normal file
19
pkg/libcrypto/hash.go
Normal file
|
@ -0,0 +1,19 @@
|
|||
package libcrypto
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
)
|
||||
|
||||
// HashFromBytes returns the hash of the specified data
|
||||
func HashFromBytes(data []byte) []byte {
|
||||
digest := md5.New()
|
||||
digest.Write(data)
|
||||
return digest.Sum(nil)
|
||||
}
|
||||
|
||||
// Hash32Bit returns a hexadecimal encoded hash
|
||||
func Hash32Bit(data []byte) []byte {
|
||||
hash := HashFromBytes(data)
|
||||
return []byte(hex.EncodeToString(hash))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue