authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-07-14 17:45:03 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-07-14 17:45:03 -07:00
logaebddddaa1dd96e7a86f3ee10cb6c5e89b56d58b
tree9c9e24d88a606260ad11a4f2d384d8473755fa53
parent02301520811d7796de6e4f87961a44a6f458f702
signaturebadge-check Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

add to_HEX


2 files changed, 11 insertions(+), 0 deletions(-)

src/lib.zig+1
...@@ -40,6 +40,7 @@ pub const isArrayOf = @import("./isArrayOf.zig").isArrayOf;...@@ -40,6 +40,7 @@ pub const isArrayOf = @import("./isArrayOf.zig").isArrayOf;
40pub const parse_int = @import("./parse_int.zig").parse_int;40pub const parse_int = @import("./parse_int.zig").parse_int;
41pub const parse_bool = @import("./parse_bool.zig").parse_bool;41pub const parse_bool = @import("./parse_bool.zig").parse_bool;
42pub const to_hex = @import("./to_hex.zig").to_hex;42pub const to_hex = @import("./to_hex.zig").to_hex;
43pub const to_HEX = @import("./to_hex.zig").to_HEX;
43pub const FieldUnion = @import("./FieldUnion.zig").FieldUnion;44pub const FieldUnion = @import("./FieldUnion.zig").FieldUnion;
44pub const LoggingReader = @import("./LoggingReader.zig").LoggingReader;45pub const LoggingReader = @import("./LoggingReader.zig").LoggingReader;
45pub const LoggingWriter = @import("./LoggingWriter.zig").LoggingWriter;46pub const LoggingWriter = @import("./LoggingWriter.zig").LoggingWriter;
src/to_hex.zig+10
...@@ -22,6 +22,16 @@ pub fn to_hex(array: anytype) [array.len * 2]u8 {...@@ -22,6 +22,16 @@ pub fn to_hex(array: anytype) [array.len * 2]u8 {
22 return res;22 return res;
23}23}
2424
25pub fn to_HEX(array: anytype) [array.len * 2]u8 {
26 var res: [array.len * 2]u8 = undefined;
27 for (&array, 0..) |x, i| res[i * 2 ..][0..2].* = alphabet[@as(usize, x) * 2 ..][0..2].*;
28 for (&res) |*x| x.* = std.ascii.toUpper(x.*);
29 return res;
30}
31
25test {32test {
26 try std.testing.expect(std.mem.eql(u8, &to_hex(rawIntBytes(u64, 0x4e5a7da9f3f1d132)), "4e5a7da9f3f1d132"));33 try std.testing.expect(std.mem.eql(u8, &to_hex(rawIntBytes(u64, 0x4e5a7da9f3f1d132)), "4e5a7da9f3f1d132"));
27}34}
35test {
36 try std.testing.expect(std.mem.eql(u8, &to_hex(rawIntBytes(u64, 0x4e5a7da9f3f1d132)), "4E5A7dA9F3F1D132"));
37}