/otp

Simple, basic OTP library written in Zig.

Primary LanguageZigMIT LicenseMIT

OTP

Test

OTP is a one-time-password library supporting both HOTP and TOTP according to RFC 4226 and RFC 6238.

Currently only the generation of codes is supported. Verification has to be done by the implementation.

note

This library's primary goal was to get more familair with the Zig language.

Example

const std = @import("std");
const otp = @import("otp");
const warn = std.debug.warn;

pub fn main() !void {
    const hotp = otp.Hotp.init();
    const code = try hotp.generateCode("secretkey", 0);
    warn("code: {}\n", .{code});
}

You can use the build.zig file as reference point on how to link the library to your own project.

Tests

You can run the tests using the following command

zig build