diff --git a/hasherx/hash_comparator.go b/hasherx/hash_comparator.go index e9abaee2..be2745fe 100644 --- a/hasherx/hash_comparator.go +++ b/hasherx/hash_comparator.go @@ -164,7 +164,7 @@ func decodeArgon2idHash(encodedHash string) (p *Argon2Config, salt, hash []byte, if err != nil { return nil, nil, nil, err } - saltLength := len(salt) + saltLength := uint(len(salt)) if saltLength > math.MaxUint32 { return nil, nil, nil, ErrInvalidHash } @@ -174,7 +174,7 @@ func decodeArgon2idHash(encodedHash string) (p *Argon2Config, salt, hash []byte, if err != nil { return nil, nil, nil, err } - keyLength := len(hash) + keyLength := uint(len(hash)) if keyLength > math.MaxUint32 { return nil, nil, nil, ErrInvalidHash } @@ -207,7 +207,7 @@ func decodePbkdf2Hash(encodedHash string) (p *PBKDF2Config, salt, hash []byte, e if err != nil { return nil, nil, nil, err } - saltLength := len(salt) + saltLength := uint(len(salt)) if saltLength > math.MaxUint32 { return nil, nil, nil, ErrInvalidHash } @@ -217,7 +217,7 @@ func decodePbkdf2Hash(encodedHash string) (p *PBKDF2Config, salt, hash []byte, e if err != nil { return nil, nil, nil, err } - keyLength := len(hash) + keyLength := uint(len(hash)) if keyLength > math.MaxUint32 { return nil, nil, nil, ErrInvalidHash } diff --git a/mapx/type_assert.go b/mapx/type_assert.go index f76de985..5645f3bd 100644 --- a/mapx/type_assert.go +++ b/mapx/type_assert.go @@ -97,10 +97,11 @@ func GetInt64[K comparable](values map[K]any, key K) (int64, error) { case int32: return int64(v), nil case uint: - if v > math.MaxInt64 { + vv := uint64(v) + if vv > math.MaxInt64 { return 0, errors.New("value is out of range") } - return int64(v), nil + return int64(vv), nil case uint32: return int64(v), nil case uint64: