eltNEG/kryptograzig
Simple public key cryptography algorithms implemented in zig
Simple public key cryptography algorithms implemented in zig. For educational purposes only.
Fetch this dependency by running the following command in your project:
zig fetch --save git+https://github.com/eltNEG/kryptograzig#master
Then add the following to your build.zig
file:
b.installArtifact(exe); // this line should already be in your build.zig file
const cryptography = b.dependency("kryptograzig", .{
.target = target,
.optimize = optimize,
});
exe.root_module.addImport("kryptograzig", cryptography.module("kryptograzig"));
Import the library and use the functions as shown below:
const std = @import("std");
const kryptograzig = @import("kryptograzig");
pub fn main() !void {
std.debug.print("Hello, world!\n", .{});
const r = kryptograzig.gcd(u8, 10, 5);
std.debug.print("gcd(10, 5) = {}\n", .{r});
const alloc = std.heap.page_allocator;
const factors = try kryptograzig.factorise(u128, alloc, 2 * 2 * 17 * 17 * 19 * 19 * 29 * 29 * 97 * 97 * 101 * 101 * 103 * 103);
defer alloc.free(factors);
std.debug.print("factors = {any}\n", .{factors});
}
zig build test