{"id":16703560,"url":"https://github.com/kurtbuilds/simple2fa","last_synced_at":"2026-05-05T11:33:25.767Z","repository":{"id":122601034,"uuid":"432874757","full_name":"kurtbuilds/simple2fa","owner":"kurtbuilds","description":"Simple2FA is a simple and fast library to easily add two-factor authentication to your app. Bindings in Rust, Python, and Node.","archived":false,"fork":false,"pushed_at":"2021-12-26T01:44:09.000Z","size":38,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-18T22:36:18.105Z","etag":null,"topics":["2fa","nodejs","python","rust","security"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/kurtbuilds.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2021-11-29T01:58:09.000Z","updated_at":"2022-01-02T00:23:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"c169c367-567c-4854-8aa7-b6f578720048","html_url":"https://github.com/kurtbuilds/simple2fa","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kurtbuilds/simple2fa","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kurtbuilds%2Fsimple2fa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kurtbuilds%2Fsimple2fa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kurtbuilds%2Fsimple2fa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kurtbuilds%2Fsimple2fa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kurtbuilds","download_url":"https://codeload.github.com/kurtbuilds/simple2fa/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kurtbuilds%2Fsimple2fa/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268261595,"owners_count":24222029,"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","status":"online","status_checked_at":"2025-08-01T02:00:08.611Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["2fa","nodejs","python","rust","security"],"created_at":"2024-10-12T19:08:43.302Z","updated_at":"2026-05-05T11:33:25.722Z","avatar_url":"https://github.com/kurtbuilds.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\u003ca href=\"https://github.com/kurtbuilds/simple2fa/graphs/contributors\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/contributors/kurtbuilds/simple2fa.svg?style=flat-square\" alt=\"GitHub Contributors\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://github.com/kurtbuilds/simple2fa/stargazers\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/stars/kurtbuilds/simple2fa.svg?style=flat-square\" alt=\"Stars\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://github.com/kurtbuilds/simple2fa/actions\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/workflow/status/kurtbuilds/simple2fa/test?style=flat-square\" alt=\"Build Status\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://crates.io/crates/simple2fa\"\u003e\n    \u003cimg src=\"https://img.shields.io/crates/d/simple2fa?style=flat-square\" alt=\"Downloads\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://crates.io/crates/simple2fa\"\u003e\n    \u003cimg src=\"https://img.shields.io/crates/v/simple2fa?style=flat-square\" alt=\"Crates.io\" /\u003e\n\u003c/a\u003e\n\u003c/p\u003e\n\n# Simple2FA\n\n\nSimple2FA is a library to easily add two-factor authentication to your app.\n\n```rust\nuse simple2fa;\nuse simple2fa::create_url_encoded_qrcode;\n\n// This represnts a user in your database.\nstruct User {\n    pub otp_secret: String,\n    pub name: String,\n}\n\nfn main() {\n    // Save this to your database.\n    let user = User {\n        name: \"Marie Curie\".to_string(),\n        otp_secret: simple2fa::generate_secret()\n    };\n\n\n    // Use this function or `create_png_qrcode` to generate a png file.\n    let qrcode_data_url = create_urlencoded_qrcode(\"My web app\", user.name, user.otp_secret);\n\n    // The QR code is a data url, so you can render it inline on a web page.\n    println!(r#\"\u003c!-- index.html --\u003e\n    \u003cimg src=\"{}\"/\u003e\n    \"#, qrcode_data_url);\n\n    // Ask the user to scan the QR code with an authenticator app, \n    // and request a code to confirm they have setup 2FA.\n    if simple2fa.check_2fa_code(user.otp_secret, \"\u003cotp_code\u003e\") {\n        // 2FA is setup!\n    } else {\n        // Something went wrong setting up 2FA. Have the user submit a code again.\n    }\n\n    // When the user logs in, validate their password, then respond with \n    // a form requesting a 2FA code, putting the user_id in JWT or similar server-signed\n    // wrapper.\n    if simple2fa.check_2fa_code(user.otp_secret, \"\u003cotp_code\u003e\") {\n        // Log in successful\n    } else {\n        // Log in failed. Ask user re-enter an otp code or reject their login attempt.\n    }\n}\n```\n\n# Installation\n\nAdd `simple2fa` to your `Cargo.toml`:\n\n    [dependencies]\n    simple2fa = \"0.1.0\"\n\nIf you have `cargo-edit`, you can use the command line:\n\n    cargo add simple2fa\n\nSimple2FA is also available in other languages:\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"/node\"\u003e\n    \u003cimg src=\"https://github.com/kurtbuilds/logos/blob/9e56858d368da9e05a517c81ce28394f82d6b2fa/programming/node.png?raw=true\" width=\"96px\"/\u003e\n\u003c/a\u003e\n\u003ca href=\"/python\"\u003e\n    \u003cimg src=\"https://github.com/kurtbuilds/logos/blob/9e56858d368da9e05a517c81ce28394f82d6b2fa/programming/python.png?raw=true\" width=\"96px\"/\u003e\n\u003c/a\u003e\n\u003ca href=\"https://github.com/kurtbuilds/simple2fa/\"\u003e\n    \u003cimg src=\"https://github.com/kurtbuilds/logos/blob/9e56858d368da9e05a517c81ce28394f82d6b2fa/programming/rust.png?raw=true\" width=\"96px\"/\u003e\n\u003c/a\u003e\n\u003c/p\u003e\n\n# Development\n\nDevelopment commands are described in the `Justfile`.\n\n# Appreciation\n\nThank you to:\n\n- [@fosskers](https://github.com/fosskers) for the Rust [totp-lite](https://github.com/fosskers/totp-lite) library,\n  which this library depends on. `totp-lite` beat similar Rust libraries in benchmarking.\n- The [neon](https://neon-bindings.com/) project, which makes creating Node libraries painless.\n- The [pyo3](https://pyo3.rs/) project, which makes creating Python libraries painless.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkurtbuilds%2Fsimple2fa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkurtbuilds%2Fsimple2fa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkurtbuilds%2Fsimple2fa/lists"}