I have this code
test "hash" {
const print = @import("std").debug.print;
const Sha256 = std.crypto.hash.sha2.Sha256;
var sha256 = Sha256.init(.{});
sha256.update("Hello Zig");
const result = sha256.finalResult();
print("hash = {any}\n", .{result});
try std.testing.expect(true);
}
And this prints out
1/1 main.test.hash...hash = { 183, 1, 163, 9, 115, 145, 245, 17, 24, 123, 13, 198, 11, 35, 242, 192, 5, 58, 186, 238, 166, 209, 248, 225, 225, 150, 206, 39, 172, 180, 55, 45 }
OK
All 1 tests passed.
How do I get this binary array as hex string?
When I run the hash via the terminal I get the following
echo -n "Hello Zig" | shasum -a 256
b701a3097391f511187b0dc60b23f2c0053abaeea6d1f8e1e196ce27acb4372d -
I tried formatting with X, but this is what I got instead
main.test.hash...hash = { B7, 1, A3, 9, 73, 91, F5, 11, 18, 7B, D, C6, B, 23, F2, C0, 5, 3A, BA, EE, A6, D1, F8, E1, E1, 96, CE, 27, AC, B4, 37, 2D }
OK
All 1 tests passed.
Which is basically what I want, only that I am not sure how to get the result formatted as a string instead