{"id":26158043,"url":"https://github.com/eendroroy/rusotp","last_synced_at":"2025-04-14T09:41:39.020Z","repository":{"id":272144837,"uuid":"915596573","full_name":"eendroroy/rusotp","owner":"eendroroy","description":null,"archived":false,"fork":false,"pushed_at":"2025-04-09T05:42:28.000Z","size":181,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-09T06:30:42.705Z","etag":null,"topics":["hotp","otp","totp"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eendroroy.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-01-12T09:41:16.000Z","updated_at":"2025-04-09T05:42:31.000Z","dependencies_parsed_at":"2025-03-11T10:36:07.982Z","dependency_job_id":"8bd19e7d-18f1-404b-83e3-e8f63385a6e2","html_url":"https://github.com/eendroroy/rusotp","commit_stats":null,"previous_names":["eendroroy/rusotp"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eendroroy%2Frusotp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eendroroy%2Frusotp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eendroroy%2Frusotp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eendroroy%2Frusotp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eendroroy","download_url":"https://codeload.github.com/eendroroy/rusotp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248695478,"owners_count":21146956,"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":["hotp","otp","totp"],"created_at":"2025-03-11T10:30:59.703Z","updated_at":"2025-04-14T09:41:39.012Z","avatar_url":"https://github.com/eendroroy.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rusotp\n\nOTP generation and validation library.\n\n* Implements [RFC4226](https://datatracker.ietf.org/doc/html/rfc4226)\n  and [RFC6238](https://datatracker.ietf.org/doc/html/rfc6238)\n* Supports alphanumeric OTP generation\n* Supports `HmacSha1`, `HmacSha256`, and `HmacSha512` digests\n\n**Note:** `HmacSha1` support is provided for RFC compliance.\nIt is recommended to use `HmacSha256` or `HmacSha512` for better security.\n\n## Usage HOTP\n\nTo use the `rusotp` library for HOTP, follow these steps:\n\n1. Add `rusotp` to your `Cargo.toml`:\n\n    ```toml\n    [dependencies]\n    rusotp = \"0.3.2\"\n    ```\n\n2. Import the necessary components in your Rust code:\n\n    ```rust\n    use rusotp::{Algorithm, HOTP};\n    ```\n\n3. Create a new HOTP instance and generate an OTP:\n\n    ```rust\n    const ALGORITHM: Algorithm = Algorithm::SHA256;\n    const SECRET: \u0026str = \"12345678901234567890\";\n    const LENGTH: u8 = 6;\n    const COUNTER: u64 = 1;\n\n    let hotp = HOTP::new(ALGORITHM, SECRET, LENGTH, 10).unwrap();\n    let otp = hotp.generate(COUNTER).unwrap();\n    println!(\"Generated OTP: {}\", otp);\n    ```\n\n4. Verify an OTP:\n\n    ```rust\n    let is_valid = hotp.verify(\"287082\", COUNTER, 0).unwrap();\n    println!(\"Is OTP valid? {}\", is_valid);\n    ```\n\n5. Generate a provisioning URI for use with OTP apps like Google Authenticator:\n\n    ```rust\n    const ISSUER: \u0026str = \"MyService\";\n    const NAME: \u0026str = \"user@example.com\";\n\n    let uri = hotp.provisioning_uri(ISSUER, NAME, COUNTER).unwrap();\n    println!(\"Provisioning URI: {}\", uri);\n    ```\n\nFor more examples and detailed usage, refer to the [documentation](https://docs.rs/rusotp).\n\n## Usage TOTP\n\nTo use the `rusotp` library, follow these steps:\n\n1. Add `rusotp` to your `Cargo.toml`:\n\n    ```toml\n    [dependencies]\n    rusotp = \"0.3.2\"\n    ```\n\n2. Import the necessary components in your Rust code:\n\n    ```rust\n    use rusotp::{Algorithm, TOTP};\n    ```\n\n3. Create a new TOTP instance and generate an OTP:\n\n    ```rust\n    const ALGORITHM: Algorithm = Algorithm::SHA256;\n    const SECRET: \u0026str = \"12345678901234567890\";\n    const LENGTH: u8 = 6;\n    const RADIX: u8 = 10;\n    const INTERVAL: u8 = 30;\n\n    let totp = TOTP::new(ALGORITHM, SECRET, LENGTH, RADIX, INTERVAL).unwrap();\n    let otp = totp.generate().unwrap();\n    println!(\"Generated OTP: {}\", otp);\n    ```\n\n4. Verify an OTP:\n\n    ```rust\n    let is_valid = totp.verify(\u0026otp);\n    println!(\"Is OTP valid? {}\", is_valid);\n    ```\n\n5. Generate a provisioning URI for use with OTP apps like Google Authenticator:\n\n    ```rust\n    const ISSUER: \u0026str = \"MyService\";\n    const NAME: \u0026str = \"user@example.com\";\n\n    let uri = totp.provisioning_uri(ISSUER, NAME).unwrap();\n    println!(\"Provisioning URI: {}\", uri);\n    ```\n\nFor more examples and detailed usage, refer to the [documentation](https://docs.rs/rusotp).\n\n## Contributing\n\nWe welcome contributions to the [rusotp](https://github.com/eendroroy/rusotp) project! Here are some ways you can help:\n\n1. **Report Bugs**: If you find a bug, please report it by opening an issue on GitHub.\n2. **Suggest Features**: If you have an idea for a new feature, please open an issue to discuss it.\n3. **Submit Pull Requests**: If you want to contribute code, follow these steps:\n    1. Fork the repository (https://github.com/eendroroy/rusotp/fork)\n    2. Create a new branch (`git checkout -b my-new-feature`)\n    3. Make your changes and commit them (`git commit -am 'Add some feature'`)\n    4. Push to the branch (`git push origin my-new-feature`)\n    5. Open a Pull Request\n\nPlease make sure your contributions adhere to our [Code of Conduct](http://contributor-covenant.org).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feendroroy%2Frusotp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feendroroy%2Frusotp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feendroroy%2Frusotp/lists"}