Select Git revision
encryption.go
-
Francé Wilke authoredFrancé Wilke authored
encryption.go 430 B
package encryption
import (
"crypto/hmac"
"crypto/md5"
"crypto/sha256"
"encoding/base64"
"fmt"
)
func Hash(input string, key string) string {
keyBytes := []byte(key)
h := hmac.New(sha256.New, keyBytes)
h.Write([]byte(input))
return base64.StdEncoding.EncodeToString(h.Sum(nil))
}
func Md5HashString(bytesToHash []byte) string {
hash := md5.Sum(bytesToHash)
hashString := fmt.Sprintf("%X", hash)
return hashString
}