Adding missing bcrypt library to imports

This commit is contained in:
DanB
2020-11-02 14:13:06 +01:00
parent 4a0466f797
commit cd57f86e5a
2 changed files with 5 additions and 2 deletions

1
go.mod
View File

@@ -60,6 +60,7 @@ require (
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect
github.com/xdg/stringprep v1.0.1-0.20180714160509-73f8eece6fdc // indirect
go.mongodb.org/mongo-driver v1.4.0
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
golang.org/x/net v0.0.0-20200707034311-ab3426394381
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
google.golang.org/api v0.29.0

View File

@@ -44,6 +44,7 @@ import (
"time"
"github.com/cgrates/rpcclient"
"golang.org/x/crypto/bcrypt"
)
var (
@@ -995,7 +996,7 @@ func AESDecrypt(encrypted string, encKey string) (txt string, err error) {
}
// Hash generates the hash text
func Hash(dataKeys ...string) (lns string, err error) {
func ComputeHash(dataKeys ...string) (lns string, err error) {
var hashByts []byte
if hashByts, err = bcrypt.GenerateFromPassword(
[]byte(ConcatenatedKey(dataKeys...)),
@@ -1007,6 +1008,7 @@ func Hash(dataKeys ...string) (lns string, err error) {
// VerifyHash matches the data hash with the dataKeys ha
func VerifyHash(hash string, dataKeys ...string) bool {
err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(ConcatenatedKey(dataKeys...)))
err := bcrypt.CompareHashAndPassword([]byte(hash),
[]byte(ConcatenatedKey(dataKeys...)))
return err == nil
}