From 8374be1a1c6cba12ec01d7a6301a8da0a00907f4 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 12 Sep 2020 00:50:37 -0700 Subject: [PATCH] std.cache_hash: bump up the base64 digest len to avoid '==' --- lib/std/cache_hash.zig | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/std/cache_hash.zig b/lib/std/cache_hash.zig index f98ec8d7f1..4727169407 100644 --- a/lib/std/cache_hash.zig +++ b/lib/std/cache_hash.zig @@ -16,8 +16,9 @@ const Allocator = std.mem.Allocator; const base64_encoder = fs.base64_encoder; const base64_decoder = fs.base64_decoder; -/// This is 128 bits - Even with 2^54 cache entries, the probably of a collision would be under 10^-6 -const BIN_DIGEST_LEN = 16; +/// 16 would be 128 bits - Even with 2^54 cache entries, the probably of a collision would be under 10^-6 +/// We round up to 18 to avoid the `==` padding after base64 encoding. +const BIN_DIGEST_LEN = 18; const BASE64_DIGEST_LEN = base64.Base64Encoder.calcSize(BIN_DIGEST_LEN); const MANIFEST_FILE_SIZE_MAX = 50 * 1024 * 1024;