Skip to content

Commit

Permalink
refactor: remove unnecessary type conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
ci42 committed Mar 23, 2023
1 parent be15aa8 commit 551aa3b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions hash/hash_comparator.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func CompareArgon2id(_ context.Context, password []byte, hash []byte) error {
}

// Derive the key from the other password using the same parameters.
otherHash := argon2.IDKey([]byte(password), salt, p.Iterations, uint32(p.Memory), p.Parallelism, p.KeyLength)
otherHash := argon2.IDKey(password, salt, p.Iterations, uint32(p.Memory), p.Parallelism, p.KeyLength)

return comparePasswordHashConstantTime(hash, otherHash)
}
Expand All @@ -92,7 +92,7 @@ func CompareArgon2i(_ context.Context, password []byte, hash []byte) error {
}

// Derive the key from the other password using the same parameters.
otherHash := argon2.Key([]byte(password), salt, p.Iterations, uint32(p.Memory), p.Parallelism, p.KeyLength)
otherHash := argon2.Key(password, salt, p.Iterations, uint32(p.Memory), p.Parallelism, p.KeyLength)

return comparePasswordHashConstantTime(hash, otherHash)
}
Expand Down
2 changes: 1 addition & 1 deletion hash/hasher_argon2.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (h *Argon2) Generate(ctx context.Context, password []byte) ([]byte, error)
// Pass the plaintext password, salt and parameters to the argon2.IDKey
// function. This will generate a hash of the password using the Argon2id
// variant.
hash := argon2.IDKey([]byte(password), salt, p.Iterations, toKB(p.Memory), p.Parallelism, p.KeyLength)
hash := argon2.IDKey(password, salt, p.Iterations, toKB(p.Memory), p.Parallelism, p.KeyLength)

var b bytes.Buffer
if _, err := fmt.Fprintf(
Expand Down

0 comments on commit 551aa3b

Please sign in to comment.