{"id":27135533,"url":"https://github.com/itpey/totp","last_synced_at":"2025-04-08T01:48:32.146Z","repository":{"id":285563838,"uuid":"958520916","full_name":"itpey/totp","owner":"itpey","description":"High-performance and secure TOTP generator and validator in Go, supporting multiple hashing algorithms: SHA1, SHA256, SHA512, and BLAKE2.","archived":false,"fork":false,"pushed_at":"2025-04-01T12:25:02.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-01T13:27:31.819Z","etag":null,"topics":["auth","authenticator","black2b","black3","go","gocrypt","golang","google-authenticator","googleauthenticator","hmac","hmac-sha256","md5","otp","sha1","sha256","sha3","totp","totp-authenticator","totp-generator"],"latest_commit_sha":null,"homepage":"https://github.com/itpey/totp","language":"Go","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/itpey.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":"2025-04-01T10:32:46.000Z","updated_at":"2025-04-01T12:25:06.000Z","dependencies_parsed_at":"2025-04-01T13:27:36.164Z","dependency_job_id":"a4391397-ffca-48eb-b488-900b43d5f9ad","html_url":"https://github.com/itpey/totp","commit_stats":null,"previous_names":["itpey/totp"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itpey%2Ftotp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itpey%2Ftotp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itpey%2Ftotp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itpey%2Ftotp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/itpey","download_url":"https://codeload.github.com/itpey/totp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247761028,"owners_count":20991533,"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":["auth","authenticator","black2b","black3","go","gocrypt","golang","google-authenticator","googleauthenticator","hmac","hmac-sha256","md5","otp","sha1","sha256","sha3","totp","totp-authenticator","totp-generator"],"created_at":"2025-04-08T01:48:31.620Z","updated_at":"2025-04-08T01:48:32.137Z","avatar_url":"https://github.com/itpey.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TOTP (Time-Based One-Time Password) Generator\n\n[![Go Version][GoVer-Image]][GoDoc-Url] [![License MIT][License-Image]][License-Url] [![GoDoc][GoDoc-Image]][GoDoc-Url] [![Go Report Card][ReportCard-Image]][ReportCard-Url]\n\n[GoVer-Image]: https://img.shields.io/badge/Go-1.24%2B-blue\n[GoDoc-Url]: https://pkg.go.dev/github.com/itpey/totp\n[GoDoc-Image]: https://pkg.go.dev/badge/github.com/itpey/totp.svg\n[ReportCard-Url]: https://goreportcard.com/report/github.com/itpey/totp\n[ReportCard-Image]: https://goreportcard.com/badge/github.com/itpey/totp?style=flat\n[License-Url]: https://github.com/itpey/totp/blob/main/LICENSE\n[License-Image]: https://img.shields.io/github/license/itpey/totp\n\nA high-performance and secure TOTP (Time-Based One-Time Password) generator and validator implemented in Go that supports multiple hashing algorithms, including SHA1, SHA256, SHA512, and BLAKE2.\n\n## Features\n\n- Efficient HMAC pooling to optimize performance.\n- Supports multiple hashing algorithms (SHA1, SHA256, SHA512, BLAKE2, etc.).\n- Customizable TOTP settings (digits, time period, skew allowance).\n- Secure validation with constant-time comparison.\n\n## Installation\n\n```sh\ngo get -u github.com/itpey/totp\n```\n\n## Usage\n\n### Generate a TOTP Code\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/itpey/totp\"\n)\n\nfunc main() {\n\tgenerator := totp.New(totp.Config{\n\t\tSecret:    \"JBSWY3DPEHPK3PXP\", // Base32 encoded secret key\n\t\tAlgorithm: totp.AlgorithmSHA1,\n\t\tDigits:    totp.DigitsSix,\n\t\tPeriod:    30,\n\t\tSkew:      1,\n\t})\n\n\tcode, err := generator.Generate()\n\tif err != nil {\n\t\tfmt.Println(\"Error generating TOTP:\", err)\n\t\treturn\n\t}\n\n\tfmt.Println(\"Generated TOTP Code:\", code)\n}\n```\n\n### Validate a TOTP Code\n\n```go\nvalid, err := generator.Validate(\"123456\")\nif err != nil {\n\tfmt.Println(\"Validation error:\", err)\n} else if valid {\n\tfmt.Println(\"TOTP is valid!\")\n} else {\n\tfmt.Println(\"TOTP is invalid!\")\n}\n```\n\n## Configuration\n\n| Field       | Type        | Default | Description                  |\n| ----------- | ----------- | ------- | ---------------------------- |\n| `Secret`    | `string`    | ---     | Base32 encoded secret key    |\n| `Algorithm` | `Algorithm` | SHA1    | Hashing algorithm            |\n| `Digits`    | `Digits`    | 6       | Number of digits in OTP      |\n| `Period`    | `int64`     | 30      | Time step in seconds         |\n| `Skew`      | `int64`     | 1       | Allowed time skew in periods |\n\n## Supported Hashing Algorithms\n\n- SHA1\n- SHA224\n- SHA256\n- SHA384\n- SHA512\n- SHA3-224\n- SHA3-256\n- SHA3-384\n- SHA3-512\n- BLAKE2S-256\n- BLAKE2B-256\n- BLAKE2B-384\n- BLAKE2B-512\n- MD5\n\n## Feedback and Contributions\n\nIf you encounter any issues or have suggestions for improvement, please [open an issue](https://github.com/itpey/totp/issues) on GitHub.\n\nWe welcome contributions! Fork the repository, make your changes, and submit a pull request.\n\n## License\n\nTOTP is open-source software released under the MIT License. You can find a copy of the license in the [LICENSE](https://github.com/itpey/totp/blob/main/LICENSE) file.\n\n## Author\n\nTOTP was created by [itpey](https://github.com/itpey)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitpey%2Ftotp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fitpey%2Ftotp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitpey%2Ftotp/lists"}