-
Notifications
You must be signed in to change notification settings - Fork 2
ServiceId is too short #2
Copy link
Copy link
Open
Description
Hi,
And congrats for that nice project!
Just glancing at the source code:
// Generate service ID from name using cryptographic hash to prevent collisions
fn generateServiceId(name: []const u8) tunnel.ServiceId {
var hasher = std.crypto.hash.Blake3.init(.{});
hasher.update(name);
var hash: [32]u8 = undefined;
hasher.final(&hash);
// Use first 2 bytes of hash, ensure non-zero
const id = std.mem.readInt(u16, hash[0..2], .little);
return if (id == 0) 1 else id;
}2 bytes is not enough to prevent collisions. And if you really want a short identifier (like 2, 4 or 8 bytes) on short text inputs, std.hash.crc, std.hash.fnv or std.hash.xxhash.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels