GitXplorerGitXplorer
t

zig-ksuid

public
3 stars
0 forks
0 issues

Commits

List of commits on branch main.
Unverified
6b45deee113aa881cb9100cad876d64f618e2efd

update for zig 0.9.0

ttoffaletti committed 3 years ago
Unverified
c76b0b0ee5d24c6011fa7f50e33da90f76fca7c3

run zig fmt

committed 3 years ago
Unverified
e718d9beb40ff883bec885dca4f571abb2261008

add github workflow ci

committed 3 years ago
Unverified
9af90285667e73e487034e405bf2b9ddd60f241d

update README

committed 3 years ago
Verified
30445146e243b0f0723cfc8c685046ce2a8ebf8c

Create LICENSE

ttoffaletti committed 3 years ago
Unverified
339b767e1ce957f44a98a87762be0030b5bc3de2

add README

committed 3 years ago

README

The README file for this repository.

zig-ksuid

Zig implementation of Segment.io's KSUID. A mostly direct port of the original Go implementation https://github.com/segmentio/ksuid.

library usage

To generate a KSUID you must provide a std.rand.Random. In this example we are using the default cryptographically secure rng provided by the zig std library.

    var secret_seed: [std.rand.DefaultCsprng.secret_seed_length]u8 = undefined;
    std.crypto.random.bytes(&secret_seed);
    var rand = std.rand.DefaultCsprng.init(secret_seed);
    const k = KSUID.random(rand.random());
    try stdout.print("{s}\n", .{k.fmt()});
    const k = try KSUID.parse("1srOrx2ZWZBpBUvZwXKQmoEYga2");

command usage

Generate ksuid;

./zig-out/bin/ksuid -n 5
21ZJr2CvT4q9YneIlvRsN2EH6MH
21ZJqz7FW1eU8jMUyuyoXRx2YIK
21ZJr2kAQeAiRqznp6UHyvvuk4k
21ZJqw99HJdsL9DhYBF1XwffcVp
21ZJr0QfjoyHkAwP8PL0GGs17e9

Inspect a ksuid:

./zig-out/bin/ksuid 0ujtsYcgvSTl8PAuAdqWYSMnLOv
0ujtsYcgvSTl8PAuAdqWYSMnLOv
 2017-10-09 21:00:47 -0700 PDT
 B5A1CD34B5F99D1154FB6853345C9735

test coverage

To generate a coverage report with kcov:

zig build test -Dcoverage
open kcov-output/index.html