{"id":21478061,"url":"https://github.com/ichtrojan/gotp","last_synced_at":"2026-02-22T18:04:03.550Z","repository":{"id":262172884,"uuid":"868206513","full_name":"ichtrojan/gotp","owner":"ichtrojan","description":"Golang OTP package","archived":false,"fork":false,"pushed_at":"2024-10-06T21:52:59.000Z","size":10,"stargazers_count":13,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-16T21:49:12.380Z","etag":null,"topics":["go","golang","otp","redis"],"latest_commit_sha":null,"homepage":"","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/ichtrojan.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-10-05T18:46:50.000Z","updated_at":"2025-01-27T01:19:16.000Z","dependencies_parsed_at":"2024-11-11T01:32:16.537Z","dependency_job_id":"d17f1ce8-5bf3-475f-8f86-f23fd4621ac4","html_url":"https://github.com/ichtrojan/gotp","commit_stats":null,"previous_names":["ichtrojan/gotp"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/ichtrojan/gotp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ichtrojan%2Fgotp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ichtrojan%2Fgotp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ichtrojan%2Fgotp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ichtrojan%2Fgotp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ichtrojan","download_url":"https://codeload.github.com/ichtrojan/gotp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ichtrojan%2Fgotp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29721059,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-22T15:10:41.462Z","status":"ssl_error","status_checked_at":"2026-02-22T15:10:04.636Z","response_time":110,"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":["go","golang","otp","redis"],"created_at":"2024-11-23T11:16:25.796Z","updated_at":"2026-02-22T18:04:03.524Z","avatar_url":"https://github.com/ichtrojan.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GOTP\n\nGOTP is a simple and efficient Go package for generating and verifying one-time passwords (OTPs) using Redis for storage. It provides support for different formats of tokens including alphabetic, alphanumeric, and numeric tokens.\n\n\u003e**NOTE**\u003cbr/\u003e\n\u003e * This package is named after the GOAT of Formula one, none other than [Goatifi](https://en.wikipedia.org/wiki/Nicholas_Latifi) himself\n\u003e * Not named after Go + OTP 🤣\n\n## Features\n* Generate one-time passwords with specified length and format.\n* Store tokens in Redis with an expiration time.\n* Verify tokens against stored values in Redis.\n* Automatic token deletion upon successful verification.\n\n## Installation\n\nTo install the GOTP package, use the following command:\n\n```bash\ngo get github.com/ichtrojan/gotp\n```\n\n## Prerequisites\n* Go 1.16 or later.\n* A running instance of Redis.\n\n## Configuration\n\nYou need to create a configuration that includes a Redis client before using the package.\n\n## Example Configuration\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n    \t\"time\"\n\t\"github.com/go-redis/redis/v9\"\n\t\"github.com/ichtrojan/gotp\"\n)\n\nfunc main() {\n    rdb := redis.NewClient(\u0026redis.Options{\n        Addr: \"localhost:6379\",\n    })\n\n\totp, err := gotp.New(gotp.Config{Redis: rdb})\n\tif err != nil {\n\t\tlog.Fatalf(\"Failed to connect to Redis: %v\", err)\n\t}\n\n\t// Continue with token generation and verification...\n}\n```\n\n## Usage\n\n### Generating a Token\n\nYou can generate a token by creating a Generate payload and calling the Generate method on your Config instance.\n\n```go\npackage main\n\nimport (\n    \t\"fmt\"\n    \t\"log\"\n    \t\"time\"\n\t\"github.com/go-redis/redis/v9\"\n\t\"github.com/ichtrojan/gotp\"\n)\n\nfunc main() {\n    // (Assuming Redis client setup as above)\n\n\tpayload := gotp.Generate{\n\t\tFormat:     gotp.ALPHA, // or gotp.ALPHA_NUMERIC, gotp.NUMERIC\n\t\tLength:     6,\n\t\tIdentifier: \"testIdentifier\",\n\t\tExpires:    10 * time.Minute,\n\t}\n\n\ttoken, err := otp.Generate(payload)\n\tif err != nil {\n\t\tlog.Fatalf(\"Error generating token: %v\", err)\n\t}\n\n\tfmt.Printf(\"Generated Token: %s\\n\", token)\n}\n```\n\n### Verifying a Token\n\nTo verify a token, create a Verify payload and call the Verify method.\n\n```go\npayload := gotp.Verify{\n    Token:      token, // The token you want to verify\n    Identifier: \"testIdentifier\",\n}\n\nvalid, err := otp.Verify(payload)\n\nif err != nil {\n    log.Fatalf(\"Error verifying token: %v\", err)\n}\n\nif valid {\n    fmt.Println(\"Token is valid!\")\n} else {\n    fmt.Println(\"Token is invalid or expired.\")\n}\n```\n\n## Token Formats\n\nThe Generate struct has a Format field which can take the following values:\n\n* `ALPHA`: Generates a token with alphabetic characters only.\n* `ALPHA_NUMERIC`: Generates a token with both alphabetic and numeric characters.\n* `NUMERIC`: Generates a token with numeric characters only.\n\n## License\n\nThis package is licensed under the MIT License. See the LICENSE file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fichtrojan%2Fgotp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fichtrojan%2Fgotp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fichtrojan%2Fgotp/lists"}