1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-19 05:19:39 +02:00
portainer/pkg/libcrypto/hash.go

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

20 lines
383 B
Go
Raw Permalink Normal View History

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))
}