{"id":47444090,"url":"https://github.com/bad-antics/TOTP.jl","last_synced_at":"2026-04-06T13:00:56.907Z","repository":{"id":344644552,"uuid":"1182526439","full_name":"bad-antics/TOTP.jl","owner":"bad-antics","description":"RFC 4226/6238 HOTP \u0026 TOTP implementation for Julia — Time-based One-Time Passwords for 2FA","archived":false,"fork":false,"pushed_at":"2026-03-15T17:19:30.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-16T05:43:20.189Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Julia","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bad-antics.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":"2026-03-15T16:33:37.000Z","updated_at":"2026-03-15T16:36:41.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/bad-antics/TOTP.jl","commit_stats":null,"previous_names":["bad-antics/totp.jl"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/bad-antics/TOTP.jl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bad-antics%2FTOTP.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bad-antics%2FTOTP.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bad-antics%2FTOTP.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bad-antics%2FTOTP.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bad-antics","download_url":"https://codeload.github.com/bad-antics/TOTP.jl/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bad-antics%2FTOTP.jl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31473271,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-06T08:36:52.050Z","status":"ssl_error","status_checked_at":"2026-04-06T08:36:51.267Z","response_time":112,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2026-03-23T06:00:59.902Z","updated_at":"2026-04-06T13:00:56.900Z","avatar_url":"https://github.com/bad-antics.png","language":"Julia","funding_links":[],"categories":["Cryptography"],"sub_categories":["Cryptographic Utilities"],"readme":"# TOTP.jl\n\n[![Build Status](https://github.com/bad-antics/TOTP.jl/workflows/CI/badge.svg)](https://github.com/bad-antics/TOTP.jl/actions)\n\nRFC 4226 (HOTP) and RFC 6238 (TOTP) implementation for Julia — Time-based and HMAC-based One-Time Passwords for two-factor authentication.\n\n## Features\n\n- **HOTP** (RFC 4226) — HMAC-based One-Time Passwords\n- **TOTP** (RFC 6238) — Time-based One-Time Passwords\n- **Verification** with configurable time windows and constant-time comparison\n- **Base32** encoding/decoding (RFC 4648)\n- **Secret generation** with cryptographically secure random bytes\n- **OTPAuth URI** generation for QR code provisioning (Google Authenticator, Authy, etc.)\n- **Multiple hash algorithms** — SHA-1, SHA-256, SHA-512\n- **Zero dependencies** beyond Julia stdlib (SHA.jl)\n\n## Installation\n\n```julia\nusing Pkg\nPkg.add(url=\"https://github.com/bad-antics/TOTP.jl\")\n```\n\n## Quick Start\n\n```julia\nusing TOTP\n\n# Generate a random secret\nsecret = generate_secret()\n\n# Get the current TOTP code\ncode = totp(secret)\nprintln(\"Your code: $code\")\n\n# Verify a code (with ±1 time step window)\nis_valid = verify_totp(secret, code)\nprintln(\"Valid: $is_valid\")\n\n# Generate URI for authenticator apps\nuri = otpauth_uri(secret, \"user@example.com\", \"MyApp\")\nprintln(uri)\n# =\u003e otpauth://totp/MyApp:user%40example.com?secret=...\u0026issuer=MyApp\n```\n\n## API Reference\n\n### TOTP\n\n```julia\ntotp(secret; digits=6, period=30, algorithm=:SHA1, time=time())\n```\n\nGenerate a time-based OTP. `secret` can be raw bytes (`Vector{UInt8}`) or a Base32-encoded string.\n\n### HOTP\n\n```julia\nhotp(secret, counter; digits=6, algorithm=:SHA1)\n```\n\nGenerate an HMAC-based OTP for the given counter value.\n\n### Verification\n\n```julia\nverify_totp(secret, code; window=1, digits=6, period=30, algorithm=:SHA1)\nverify_hotp(secret, code, counter; look_ahead=0, digits=6, algorithm=:SHA1)\n```\n\nVerify OTP codes. `verify_totp` checks ±`window` time steps. `verify_hotp` returns `(valid::Bool, matched_counter::Int)`.\n\n### Key Management\n\n```julia\nsecret = generate_secret(nbytes=20)  # Base32-encoded random key\nuri = otpauth_uri(secret, \"user@example.com\", \"MyApp\")\n```\n\n### Base32\n\n```julia\nencoded = base32_encode(\"Hello\")  # =\u003e \"JBSWY3DP\"\ndecoded = base32_decode(\"JBSWY3DP\")  # =\u003e UInt8[0x48, 0x65, 0x6c, 0x6c, 0x6f]\n```\n\n## RFC Compliance\n\nValidated against all test vectors from:\n- [RFC 4226](https://tools.ietf.org/html/rfc4226) — HOTP (Appendix D)\n- [RFC 6238](https://tools.ietf.org/html/rfc6238) — TOTP (Appendix B)\n- [RFC 4648](https://tools.ietf.org/html/rfc4648) — Base32 Encoding\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbad-antics%2FTOTP.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbad-antics%2FTOTP.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbad-antics%2FTOTP.jl/lists"}