{"id":36383934,"url":"https://github.com/imseyed/auth2fa","last_synced_at":"2026-01-11T15:00:12.182Z","repository":{"id":251877339,"uuid":"780736240","full_name":"imseyed/Auth2FA","owner":"imseyed","description":"A PHP library for Two-Factor Authentication (2FA) providing TOTP and HOTP generation, and  random secret key generation functionalities. (2FA Algorithm PHP)","archived":false,"fork":false,"pushed_at":"2024-08-06T09:02:20.000Z","size":7,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-05T16:42:02.736Z","etag":null,"topics":["2fa","authentication","hotp","otp-verification","php","totp"],"latest_commit_sha":null,"homepage":"","language":"PHP","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/imseyed.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}},"created_at":"2024-04-02T04:06:49.000Z","updated_at":"2025-09-12T10:56:17.000Z","dependencies_parsed_at":"2024-08-06T09:47:49.552Z","dependency_job_id":"76afdaf6-1ced-41bb-8518-9780578414c6","html_url":"https://github.com/imseyed/Auth2FA","commit_stats":null,"previous_names":["imseyed/auth2fa"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/imseyed/Auth2FA","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imseyed%2FAuth2FA","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imseyed%2FAuth2FA/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imseyed%2FAuth2FA/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imseyed%2FAuth2FA/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imseyed","download_url":"https://codeload.github.com/imseyed/Auth2FA/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imseyed%2FAuth2FA/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28309492,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T14:58:17.114Z","status":"ssl_error","status_checked_at":"2026-01-11T14:55:53.580Z","response_time":60,"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":["2fa","authentication","hotp","otp-verification","php","totp"],"created_at":"2026-01-11T15:00:10.942Z","updated_at":"2026-01-11T15:00:12.025Z","avatar_url":"https://github.com/imseyed.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Two-Factor Authentication (2FA) Library\n\nThis PHP library provides functionality for generating Time-based One Time Passwords (TOTP) and HMAC-based One Time Passwords (HOTP), commonly used in two-factor authentication (2FA) systems.\n\n## Features\n\n- **TOTP Generation**: Generate Time-based One Time Passwords.\n- **HOTP Generation**: Generate HMAC-based One Time Passwords.\n- **Random Secret Key Generation**: Generate random secret keys for use in TOTP and HOTP generation.\n\n## Usage\n\n\n### Install via composer:\n\n```\ncomposer require imseyed/auth2fa\n```\n### TOTP Generation\n\nThe `Auth2FA::TOTP` method generates a **Time-based One Time Password** using the provided secret key and optional time slice.\n[totp.example.php](examples/totp.example.php)\n```php\n$totp = imseyed\\Auth2FA::TOTP($secret, $timeSlice);\n/*\n $totp is a OPT code like: 458905\n*/\n```\n\nIf you want show expiration time of TOTP code must use `Auth2FA::expire_time`. that method return a number Unix timestamp.\n```php\n$expirationTime = imseyed\\Auth2FA::expire_time($timeSlice);\necho \"Expire on \".date(\"H:i:s\", $expirationTime).\" (\".($expirationTime - time()).\"s remind)\";\n/*\n $expirationTime is a unix timestamp like: 1722929683\n*/\n```\n\n### HOTP Generation\n\nThe `Auth2FA::HOTP` method generates an **HMAC-based One Time Password** using the provided secret key and counter value.\n[hotp.example.php](examples/hotp.example.php)\n```php\n$code = imseyed\\Auth2FA::HOTP($secret, $counter);\n/*\n $code is string like: 111222\n*/\n```\n\n### Secret Key Generation\n\nThe `Auth2FA::generateSecret` method generates a **random secret key** of the specified length.\n\n```php\n$length = 16; // Secret key lenght\n$secret = \\imseyed\\Auth2FA::generate_secret($length);\n/*\n $secret is string like: OVZ7JFIPIXE4RTCE\n*/\n```\n\n\nNote: There is no separate function to check the correctness of 2fa codes. You must use the generation functions to confirm the correctness of the codes sent by users.\n\n---\n## License\n\nThis library is released under the [MIT License](LICENSE).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimseyed%2Fauth2fa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimseyed%2Fauth2fa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimseyed%2Fauth2fa/lists"}