{"id":24926727,"url":"https://github.com/michaelwp/goTotp","last_synced_at":"2025-10-17T09:31:21.986Z","repository":{"id":252016266,"uuid":"839115265","full_name":"michaelwp/go-totp","owner":"michaelwp","description":"totp password generator","archived":false,"fork":false,"pushed_at":"2024-08-07T13:50:24.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-08-08T07:32:16.643Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/michaelwp.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-08-07T02:14:12.000Z","updated_at":"2024-08-07T03:48:15.000Z","dependencies_parsed_at":"2024-08-07T07:32:13.531Z","dependency_job_id":"d1ac67c2-a4cd-453d-92a9-9644b91a7659","html_url":"https://github.com/michaelwp/go-totp","commit_stats":null,"previous_names":["michaelwp/go-totp"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelwp%2Fgo-totp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelwp%2Fgo-totp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelwp%2Fgo-totp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelwp%2Fgo-totp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/michaelwp","download_url":"https://codeload.github.com/michaelwp/go-totp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":236795226,"owners_count":19206006,"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":"2025-02-02T12:53:13.360Z","updated_at":"2025-10-17T09:31:21.968Z","avatar_url":"https://github.com/michaelwp.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# goTotp\n\n`goTotp` is a Go package for generating Time-based One-Time Passwords (TOTP) conforming to RFC 6238.\nIt supports multiple hash algorithms, including HMAC-SHA1, HMAC-SHA256, and HMAC-SHA512.\n\n## Features\n\n- Supports HMAC-SHA1, HMAC-SHA256, and HMAC-SHA512 algorithms.\n- Configurable TOTP parameters such as digit length, time step, and initial counter value.\n- Easy-to-use interface for generating TOTPs.\n\n## Installation\n\nTo install the package, run:\n\n```sh\ngo get github.com/michaelwp/goTotp\n```\n\n## Usage\n\nHere's a step-by-step guide on how to use the `goTotp` library to generate a TOTP.\n\n### Import the Package\n\nFirst, import the package into your Go code:\n\n```go\nimport \"github.com/michaelwp/goTotp\"\n```\n\n### Create a TOTP Instance\n\nCreate an instance of the `Totp` struct with the desired configuration. For example, to create a TOTP generator using HMAC-SHA256 with a 8-digit output:\n\n```go\ntotp := go_totp.Totp{\n    Secret:    \"rahasia\",\n    Digits:    8,\n    Period:    15,\n    Algorithm: go_totp.SHA256,\n    T0:        0,\n}\n```\n\n### TOTP Struct\n\nThe `Totp` struct contains the following fields:\n\n- `Secret`: The shared secret key used for generating the TOTP.\n- `Digits`: The number of digits in the TOTP output.\n- `Period`: The time step in seconds (default is 30 seconds).\n- `Algorithm`: The hash algorithm to use (SHA1, SHA256, or SHA512).\n- `T0`: The initial counter value (default is 0).\n\n### Generating the TOTP\n\nTo generate the TOTP, call the `GenerateTOTP` method on the `Totp` instance, passing the current Unix timestamp as the argument. This method returns the generated TOTP as a string.\n\n### Example\n\nHere's a complete example demonstrating how to use the `go_totp` package:\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/michaelwp/goTotp\"\n\t\"log\"\n\t\"time\"\n)\n\nfunc main() {\n\t// Get the current Unix time\n\ttimestamp := time.Now().Unix()\n\n\t// define the variables\n\ttotp := gototp.Totp{\n\t\tSecret:    \"rahasia\",\n\t\tDigits:    8,\n\t\tPeriod:    15,\n\t\tAlgorithm: gototp.SHA256,\n\t\tT0:        0,\n\t}\n\n\t// Generate the TOTP\n\tpass, err := totp.GenerateTOTP(timestamp)\n\tif err != nil {\n\t\tlog.Println(\"GenerateTOTP error:\", err)\n\t}\n\n\t// Print the TOTP\n\tfmt.Println(\"TOTP:\", pass)\n}\n```\n\n### Running the Example\n\nTo run the example, save it to a file (e.g., `main.go`), and then run:\n\n```sh\ngo run main.go\n```\n\nThis will output a 8-digit TOTP based on the provided user ID and the current Unix time.\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n## Contributing\n\nContributions are welcome! Please open an issue or submit a pull request with your changes.\n\n## Contact\n\nFor any questions or issues, please open an issue on GitHub.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaelwp%2FgoTotp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichaelwp%2FgoTotp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaelwp%2FgoTotp/lists"}