{"id":19545718,"url":"https://github.com/ekojs/ejsotp","last_synced_at":"2026-03-03T16:40:33.946Z","repository":{"id":57677963,"uuid":"490384775","full_name":"ekojs/ejsotp","owner":"ekojs","description":"TOTP dan HOTP Library with backup codes, compatible with google authenticator","archived":false,"fork":false,"pushed_at":"2025-01-30T21:05:26.000Z","size":317,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-06T21:02:22.348Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/ekojs.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":"2022-05-09T17:39:19.000Z","updated_at":"2025-01-30T21:49:37.000Z","dependencies_parsed_at":"2024-11-11T03:41:01.215Z","dependency_job_id":"633c1c5b-7df0-45e9-9317-af92ce21bd48","html_url":"https://github.com/ekojs/ejsotp","commit_stats":{"total_commits":8,"total_committers":1,"mean_commits":8.0,"dds":0.0,"last_synced_commit":"8e3831b3eba8e25aa1875cdf8a4807fd6997233b"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ekojs%2Fejsotp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ekojs%2Fejsotp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ekojs%2Fejsotp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ekojs%2Fejsotp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ekojs","download_url":"https://codeload.github.com/ekojs/ejsotp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245136396,"owners_count":20566588,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":"2024-11-11T03:40:50.599Z","updated_at":"2026-03-03T16:40:28.912Z","avatar_url":"https://github.com/ekojs.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"OTP Library\n=============\n\nTOTP and HOTP Library with backup codes, compatible with google authenticator. Compatible with PHP \u003e= 8.2.\n\n[![Build Status](https://github.com/ekojs/ejsotp/actions/workflows/release.yml/badge.svg)](http://ekojunaidisalam.com/ejsotp/)\n[![Coverage Status](https://coveralls.io/repos/ekojs/ejsotp/badge.svg?branch=master)](https://coveralls.io/r/ekojs/ejsotp?branch=master)\n[![Latest Stable Version](https://poser.pugx.org/ekojs/otp/version.svg)](https://packagist.org/packages/ekojs/otp)\n[![PHP Version Require](https://poser.pugx.org/ekojs/otp/require/php)](https://packagist.org/packages/ekojs/otp)\n[![License](https://poser.pugx.org/ekojs/otp/license.svg)](https://packagist.org/packages/ekojs/otp)\n[![Downloads](https://poser.pugx.org/ekojs/otp/d/total.svg)](https://packagist.org/packages/ekojs/otp)\n\n## Coverage\n\nCheck this code coverage on [http://ekojunaidisalam.com/ejsotp/](http://ekojunaidisalam.com/ejsotp/)\n\n## Install\n\nFor PHP version **`\u003e= 8.2`**:\n\n```\ncomposer require ekojs/otp\n```\n\n## How to use\n### Generate TOTP (Time-Based One-Time Password) based on [RFC 6238](https://datatracker.ietf.org/doc/html/rfc6238)\n```php\n\u003c?php\nrequire_once \"vendor/autoload.php\";\n\nuse Ekojs\\Otp\\TOTP;\n\n$ejsotp = TOTP::getInstance();\n$ejsotp-\u003ecreateOTP();\n$ejsotp-\u003eotp-\u003esetLabel(\"ekojs@email.com\");\n$ejsotp-\u003eotp-\u003esetIssuer(\"My Service\");\n\necho \"The TOTP secret is: {$ejsotp-\u003eotp-\u003egetSecret()}\".PHP_EOL;\necho \"The current TOTP is: {$ejsotp-\u003eotp-\u003enow()}\".PHP_EOL;\necho \"The Uri is: {$ejsotp-\u003eotp-\u003egetProvisioningUri()}\".PHP_EOL;\n```\n\n### Verify TOTP\n```php\n$ejsotp-\u003ecreateOTP([\"secret\" =\u003e \"VE7RDW7LC45QHKVZI6SPHDQK254TKO7CPG6KHPQ4RYN4MGBBA6EAAHVYHRVAGO5LPF6XNDPAOLE3KYQHBBHPB62VFVNZURWRZUDER4A\"]);\n$ejsotp-\u003eotp-\u003esetLabel('ekojs@email.com');\n$ejsotp-\u003eotp-\u003esetIssuer(\"My Service\");\n\necho 'Current TOTP: ' . $ejsotp-\u003eotp-\u003enow() . PHP_EOL;\nvar_dump($ejsotp-\u003eotp-\u003everify(\"988942\"));\n```\n\n### Generate HOTP (HMAC-Based One-Time Password) based on [RFC 4226](http://tools.ietf.org/html/rfc4226)\n```php\nrequire_once \"vendor/autoload.php\";\n\nuse Ekojs\\Otp\\HOTP;\n\n$ejshotp = HOTP::getInstance();\n$ejshotp-\u003ecreateOTP([\"counter\" =\u003e 1000]);\n$ejshotp-\u003eotp-\u003esetLabel(\"ekojs@email.com\");\n$ejshotp-\u003eotp-\u003esetIssuer(\"My Service HOTP\");\n\necho \"The HOTP secret is: {$ejshotp-\u003eotp-\u003egetSecret()}\".PHP_EOL;\necho \"The current HOTP is: {$ejshotp-\u003eotp-\u003eat($ejshotp-\u003eotp-\u003egetCounter())}\".PHP_EOL;\necho \"The Uri is: {$ejshotp-\u003eotp-\u003egetProvisioningUri()}\".PHP_EOL;\n```\n\n### Verify HOTP\n```php\n$ejshotp-\u003ecreateOTP([\n    \"secret\" =\u003e \"HZHL2VE2RWMT2KHDQCYCLPXJRJC7T63SZFNDTLEEEJISHLQS5Y6CRDTW4D7D3GA35VMSA32NAGLXEEFDSRT63E332JQOCTDAVK4HZHI\",\n    \"counter\" =\u003e 1000\n]);\n$ejshotp-\u003eotp-\u003esetLabel(\"ekojs@email.com\");\n$ejshotp-\u003eotp-\u003esetIssuer(\"My Service HOTP\");\n\necho 'Current OTP: ' . $ejshotp-\u003eotp-\u003eat(1001) . PHP_EOL;\nvar_dump($ejshotp-\u003eotp-\u003everify(\"598162\",1001));\n```\n\n### Generate Backup Codes (Mnemonic) based on [BIP 39](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki)\n```php\necho \"Hash secret : \". hash(\"md5\",\"mysecret\").PHP_EOL; // 06c219e5bc8378f3a8a3f83b4b7e4649\necho \"Backup codes: \". implode(\" \",$ejsotp-\u003egenerateBackupCodes(\"mysecret\")).PHP_EOL;\n```\n\n### Reverse Mnemonic / Backup Codes\n```php\necho \"Reverse Mnemonic: \".$ejsotp-\u003ereverseMnemonic(\"almost awkward just jungle daring keep penalty lecture deputy fossil muscle nasty\").PHP_EOL; // 06c219e5bc8378f3a8a3f83b4b7e4649\n```\n\n### Generate QrCode compatible with [Google Authenticator](https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2)\n```php\n$result = $ejsotp-\u003egenerateQr();\necho \"\u003cimg src='\".$result-\u003egetDataUri().\"' /\u003e\";\n```\n\n### Generate QrCode with Logo and Label\n```php\n$result = $ejsotp-\u003egenerateQr(\"path_to_logo.png\",true);\necho \"\u003cimg src='\".$result-\u003egetDataUri().\"' /\u003e\";\n```\n\n### Generate QrCode with Label and without Logo\n```php\n$result = $ejsotp-\u003egenerateQr(null,true);\necho \"\u003cimg src='\".$result-\u003egetDataUri().\"' /\u003e\";\n```\n\n### Generate QrCode and Save to File\n```php\n$result = $ejsotp-\u003egenerateQr();\n$result-\u003esaveToFile(\"path/qrcode-totp.png\");\n```\n\n### Verify Using Google Authenticator\nScan this Qr using Google Authenticator\n\n![Imgur](https://i.imgur.com/FexUnMJ.png)\n\nCreate test.php, and execute it from terminal\n```php\n\u003c?php\nrequire_once \"vendor/autoload.php\";\n\nuse Ekojs\\Otp\\TOTP;\n\n$ejsotp = TOTP::getInstance();\n$ejsotp-\u003ecreateOTP([\"secret\" =\u003e \"VZCKGWRLS7CINEYALENYPH5T442LJUAFGSNCBTBQEHMN5GSVGTJCD2B7NHCZFK5FZ3QHTQ66JYDMNUI2UBWZJAYHI62VYVHVUGTO6SQ\"]);\n$ejsotp-\u003eotp-\u003esetLabel('ekojs@email.com');\n$ejsotp-\u003eotp-\u003esetIssuer(\"My Service\");\n\nvar_dump($ejsotp-\u003eotp-\u003everify(\"input code from your Google Authenticator\")); // if true the code is valid\necho 'Current OTP: ' . $ejsotp-\u003eotp-\u003enow() . PHP_EOL;\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fekojs%2Fejsotp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fekojs%2Fejsotp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fekojs%2Fejsotp/lists"}