aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen van Rijn <Kelimion@users.noreply.github.com>2025-07-20 03:14:54 +0200
committerGitHub <noreply@github.com>2025-07-20 03:14:54 +0200
commit50358380ae5fc0bc7da3ca44286d15e6fce16ec8 (patch)
tree4d281c267c265b928cf5561adf440b1627cb5642
parenta19e7845b1a174345590f347a0b02130ac284f47 (diff)
parent164bb52212c26ef82e8799475c3e69006dc10ce6 (diff)
Merge pull request #5484 from laytan/hash-bytes-to-buffer-up-to-digest-size
crypto/hash: hash_bytes_to_buffer slice result to digest size
-rw-r--r--core/crypto/hash/hash.odin5
1 files changed, 2 insertions, 3 deletions
diff --git a/core/crypto/hash/hash.odin b/core/crypto/hash/hash.odin
index d47f0ab46..66d9201cd 100644
--- a/core/crypto/hash/hash.odin
+++ b/core/crypto/hash/hash.odin
@@ -21,8 +21,7 @@ hash_string :: proc(algorithm: Algorithm, data: string, allocator := context.all
// in a newly allocated slice.
hash_bytes :: proc(algorithm: Algorithm, data: []byte, allocator := context.allocator) -> []byte {
dst := make([]byte, DIGEST_SIZES[algorithm], allocator)
- hash_bytes_to_buffer(algorithm, data, dst)
- return dst
+ return hash_bytes_to_buffer(algorithm, data, dst)
}
// hash_string_to_buffer will hash the given input and assign the
@@ -46,7 +45,7 @@ hash_bytes_to_buffer :: proc(algorithm: Algorithm, data, hash: []byte) -> []byte
update(&ctx, data)
final(&ctx, hash)
- return hash
+ return hash[:DIGEST_SIZES[algorithm]]
}
// hash_stream will incrementally fully consume a stream, and return the