{"id":16464503,"url":"https://github.com/deatil/zig-totp","last_synced_at":"2026-06-14T18:00:33.972Z","repository":{"id":212585956,"uuid":"708303399","full_name":"deatil/zig-totp","owner":"deatil","description":"A TOTP and HOTP library for zig.","archived":false,"fork":false,"pushed_at":"2026-06-06T04:39:41.000Z","size":303,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-06-06T06:19:43.422Z","etag":null,"topics":["hotp","otp","otp-generator","otp-verification","otpauth","totp","zig","zig-hotp","zig-otp","zig-totp"],"latest_commit_sha":null,"homepage":"https://github.com/deatil/zig-totp","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/deatil.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-10-22T06:24:40.000Z","updated_at":"2026-06-06T04:30:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"6016e12f-a464-42da-982b-f25f7ea58588","html_url":"https://github.com/deatil/zig-totp","commit_stats":null,"previous_names":["deatil/zig-totp"],"tags_count":23,"template":false,"template_full_name":null,"purl":"pkg:github/deatil/zig-totp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deatil%2Fzig-totp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deatil%2Fzig-totp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deatil%2Fzig-totp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deatil%2Fzig-totp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deatil","download_url":"https://codeload.github.com/deatil/zig-totp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deatil%2Fzig-totp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34331812,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-14T02:00:07.365Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hotp","otp","otp-generator","otp-verification","otpauth","totp","zig","zig-hotp","zig-otp","zig-totp"],"created_at":"2024-10-11T11:28:19.251Z","updated_at":"2026-06-14T18:00:33.963Z","avatar_url":"https://github.com/deatil.png","language":"Zig","funding_links":[],"categories":["Libraries","Network \u0026 Web"],"sub_categories":["Web Framework"],"readme":"## Zig-totp \n\nA TOTP and HOTP library for zig.\n\n\n### Why One Time Passwords?\n\nOne Time Passwords (OTPs) are an mechanism to  improve security over passwords alone. When a Time-based OTP (TOTP) is stored on a user's phone, and combined with something the user knows (Password), you have an easy on-ramp to [Multi-factor authentication](http://en.wikipedia.org/wiki/Multi-factor_authentication) without adding a dependency on a SMS provider.  This Password and TOTP combination is used by many popular websites including Google, GitHub, Facebook, Salesforce and many others.\n\nThe `zig-totp` library enables you to easily add TOTPs to your own application, increasing your user's security against mass-password breaches and malware.\n\nBecause TOTP is standardized and widely deployed, there are many [mobile clients and software implementations](http://en.wikipedia.org/wiki/Time-based_One-time_Password_Algorithm#Client_implementations).\n\n\n### Env\n\n - Zig \u003e= 0.16.0\n\n\n### Adding zig-totp as a dependency\n\nAdd the dependency to your project:\n\n```sh\nzig fetch --save=zig-totp git+https://github.com/deatil/zig-totp#main\n```\n\nor use local path to add dependency at `build.zig.zon` file\n\n```zig\n.{\n    .dependencies = .{\n        .@\"zig-totp\" = .{\n            .path = \"./lib/zig-totp\",\n        },\n        ...\n    }\n}\n```\n\nAnd the following to your `build.zig` file:\n\n```zig\nconst zig_totp_dep = b.dependency(\"zig-totp\", .{});\nexe.root_module.addImport(\"zig-totp\", zig_totp_dep.module(\"zig-totp\"));\n```\n\nThe `zig-totp` structure can be imported in your application with:\n\n```zig\nconst totp = @import(\"zig-totp\");\n```\n\n\n### Get Starting\n\n~~~zig\nconst std = @import(\"std\");\nconst totp = @import(\"zig-totp\");\n\npub fn main(init: std.process.Init) !void {\n    const io = init.io;\n\n    const alloc = std.heap.page_allocator;\n\n    const secret = \"GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ\";\n    const n = totp.time.now(io).utc();\n    const passcode = try totp.generateCode(alloc, secret, n);\n\n    defer alloc.free(passcode);\n\n    // output: \n    // generateCode: 906939\n    std.debug.print(\"generateCode: {s} \\n\", .{passcode});\n\n    const valid = totp.validate(alloc, io, passcode, secret);\n    \n    // output: \n    // validate: true\n    std.debug.print(\"validate: {} \\n\", .{valid});\n}\n~~~\n\n\n### Generate Qrcode Url\n\n~~~zig\nconst std = @import(\"std\");\nconst totp = @import(\"zig-totp\");\n\npub fn main(init: std.process.Init) !void {\n    _ = init;\n\n    const alloc = std.heap.page_allocator;\n\n    const secret = \"test-data\";\n\n    var key = try totp.generate(alloc, .{\n        .issuer = \"Example\",\n        .account_name = \"accountName\",\n        .period = 30,\n        // .secret_size = 20,\n        // use secret if secret not empty, or use secret_size to generate secret\n        .secret = secret,\n        .digits = .Six,\n        .algorithm = .SHA1,\n    });\n    defer key.deinit();\n\n    const qrcode_url = key.urlString();\n    defer alloc.free(qrcode_url);\n\n    // output: \n    // qrcode_url: otpauth://totp/Example:accountName?issuer=Example\u0026period=30\u0026digits=6\u0026secret=ORSXG5BNMRQXIYI\u0026algorithm=SHA1\n    std.debug.print(\"qrcode_url: {} \\n\", .{qrcode_url});\n}\n~~~\n\n\n### LICENSE\n\n*  The library LICENSE is `Apache2`, using the library need keep the LICENSE.\n\n\n### Copyright\n\n*  Copyright deatil(https://github.com/deatil).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeatil%2Fzig-totp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeatil%2Fzig-totp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeatil%2Fzig-totp/lists"}