Something went wrong. Try again.
My version of https://github.com/vercel-labs/fx
Something went wrong. Try again.
123456789101112131415const std = @import("std");
/// Overwrite an owned secret before returning its allocation to the allocator.pub noinline fn zeroAndFree(alloc: std.mem.Allocator, value: []u8) void { if (value.len == 0) return; std.crypto.secureZero(u8, @volatileCast(value)); alloc.free(value);}
test "zeroAndFree overwrites bytes before release" { var value = [_]u8{ 1, 2, 3 }; std.crypto.secureZero(u8, @volatileCast(value[0..])); try std.testing.expectEqualSlices(u8, &.{ 0, 0, 0 }, &value);}