const std = @import("std"); const User = @import("../user.zig"); const Self = @This(); const fingerprint_size = 512; age: std.time.Instant, info: User.Info, fingerprint: []u8, pub fn init(allocator: std.mem.Allocator, info: User.Info) !Self { var self: Self = undefined; self.info = try info.clone(allocator); self.fingerprint = try allocator.alloc(u8, fingerprint_size); try self.reset(); return self; } pub fn reset(self: *Self) !void { var raw_buffer: [fingerprint_size / 2]u8 = undefined; std.crypto.random.bytes(&raw_buffer); var writer = std.Io.Writer.fixed(self.fingerprint); writer.print("{x}", .{raw_buffer}) catch unreachable; self.age = try std.time.Instant.now(); } pub fn deinit(self: *const Self, allocator: std.mem.Allocator) void { self.info.deinit(allocator); allocator.free(self.fingerprint); }