{"id":23772190,"url":"https://github.com/fulygon/go-totp","last_synced_at":"2026-01-30T10:36:13.489Z","repository":{"id":230560815,"uuid":"779648578","full_name":"FuLygon/go-totp","owner":"FuLygon","description":"Time-Based One-Time Password (TOTP) library for Go","archived":false,"fork":false,"pushed_at":"2024-05-31T06:56:49.000Z","size":51,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-30T11:51:17.080Z","etag":null,"topics":["go","totp"],"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/FuLygon.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-03-30T12:09:56.000Z","updated_at":"2024-05-31T06:56:52.000Z","dependencies_parsed_at":"2024-04-19T12:25:41.629Z","dependency_job_id":"f9d1681f-9e76-4a4b-8646-cd32c140d928","html_url":"https://github.com/FuLygon/go-totp","commit_stats":null,"previous_names":["fulygon/go-totp"],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FuLygon%2Fgo-totp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FuLygon%2Fgo-totp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FuLygon%2Fgo-totp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FuLygon%2Fgo-totp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FuLygon","download_url":"https://codeload.github.com/FuLygon/go-totp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245467627,"owners_count":20620216,"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":["go","totp"],"created_at":"2025-01-01T04:53:35.322Z","updated_at":"2026-01-30T10:36:13.445Z","avatar_url":"https://github.com/FuLygon.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-totp\n\n[![Github tag](https://badgen.net/github/tag/FuLygon/go-totp)](https://github.com/FuLygon/go-totp/tags)\n[![GoReportCard](https://goreportcard.com/badge/github.com/FuLygon/go-totp/v2)](https://goreportcard.com/report/github.com/FuLygon/go-totp/v2)\n\nPackage `go-totp` library implements functionalities to create and validate Time-Based One-Time Password (TOTP) for Two-Factor Authentication (2FA) applications. \n\nTOTP generates temporary codes based on a shared secret key, enhancing security.\n\n## Installation\nUse `go get`\n```shell\ngo get -u github.com/FuLygon/go-totp/v2\n```\nImport package\n```go\nimport \"github.com/FuLygon/go-totp/v2\"\n```\n\n## Documentation\n[![GoDoc](https://godoc.org/github.com/FuLygon/go-totp/v2?status.svg)](https://pkg.go.dev/github.com/FuLygon/go-totp/v2#section-documentation)\n\n## Example\nSee [Example](example/main.go)\n\n## Usage\n\n### Create TOTP\n\n#### Generate or define a TOTP instance\n```go\nt, err := totp.New(totp.TOTP{\n    AccountName: \"your_account_name\",\n    Issuer:      \"your_issuer_name\",\n})\nif err != nil {\n    // handle error\n    log.Println(\"error generating QR code:\", err)\n    return\n}\n\n// optionally, define TOTP details:\nt := totp.TOTP{\n    AccountName: \"your_account_name\",\n    Issuer:      \"your_issuer_name\",\n    Algorithm:   totp.AlgorithmSHA1,\n    Digits:      6,\n    Period:      30,\n    Secret:      \"your_shared_secret\",\n}\n```\n\n#### Generate TOTP URL and QR code\n```go\n// generate TOTP URL\nurl, err := t.GetURL()\nif err != nil {\n    // handle error\n    log.Println(\"error generating TOTP URL:\", err)\n    return\n}\nfmt.Println(\"TOTP URL:\", url)\n\n// generate QR code\nqr, err := t.GetQR(256)\nif err != nil {\n    // handle error\n    log.Println(\"error generating QR code:\", err)\n    return\n}\nfmt.Println(\"QR Code Base64:\", qr.Base64)\n```\n\n### Validating TOTP code\n\n#### Create a validator instance\n```go\nv := totp.Validator{\n  Algorithm: totp.AlgorithmSHA1,\n  Digits:    6,\n  Period:    30,\n  Secret:    \"your_shared_secret\",\n}\n```\n\n#### Validate TOTP code\n```go\ncode := \"123456\" // user-provided TOTP code\n\nvalid, err := v.Validate(code)\nif err != nil {\n    // handle error\n    log.Println(\"error validating TOTP code:\", err)\n    return\n}\n\nif valid {\n    fmt.Println(\"TOTP code is valid!\")\n} else {\n    fmt.Println(\"TOTP code is invalid.\")\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffulygon%2Fgo-totp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffulygon%2Fgo-totp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffulygon%2Fgo-totp/lists"}