{"id":17874705,"url":"https://github.com/dsgriffin/freefare","last_synced_at":"2025-03-21T22:32:04.684Z","repository":{"id":57631899,"uuid":"61495384","full_name":"dsgriffin/freefare","owner":"dsgriffin","description":"Safe Rust bindings to the libfreefare library :nut_and_bolt:","archived":false,"fork":false,"pushed_at":"2024-12-21T15:59:14.000Z","size":433,"stargazers_count":4,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-18T05:51:13.235Z","etag":null,"topics":["libfreefare","nfc","rust","rust-bindings"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/freefare","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/dsgriffin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-06-19T18:58:27.000Z","updated_at":"2024-12-21T15:59:18.000Z","dependencies_parsed_at":"2022-08-31T12:03:36.165Z","dependency_job_id":null,"html_url":"https://github.com/dsgriffin/freefare","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsgriffin%2Ffreefare","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsgriffin%2Ffreefare/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsgriffin%2Ffreefare/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dsgriffin%2Ffreefare/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dsgriffin","download_url":"https://codeload.github.com/dsgriffin/freefare/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244880422,"owners_count":20525507,"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":["libfreefare","nfc","rust","rust-bindings"],"created_at":"2024-10-28T11:10:31.731Z","updated_at":"2025-03-21T22:32:04.679Z","avatar_url":"https://github.com/dsgriffin.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# freefare\n\n[![Crates.io](https://img.shields.io/crates/v/freefare.svg?maxAge=2592000)](https://crates.io/crates/freefare)\n\nRust bindings for the [libfreefare](https://github.com/nfc-tools/libfreefare) library.\n\nFor raw FFI bindings for `libfreefare`, see [freefare-sys](https://github.com/dsgriffin/freefare-sys).\n\n## Requirements\n\nYou need to install `libfreefare` and `libnfc` before using this crate.\n\n### Ubuntu + APT\n\n```bash\nsudo apt install libfreefare-dev libnfc-dev\n```\n\n### MacOS + Homebrew\n\n```bash\nbrew install libfreefare libnfc\n```\n\n### Custom Paths\n\nIf the two libraries above are not installed in the standard APT or Homebrew locations, you can override the following environment variables:\n\n* **LIBFREEFARE_PATH**: Path to libfreefare (e.g. **/path/to/libfreefare/lib**).\n* **LIBNFC_PATH**: Path to libnfc (e.g. **/path/to/libnfc/lib**).\n\nSee `build.rs` for more details on how it works if needed.\n\n## Usage\n\nAdd both `libc` and `freefare` as dependencies in your `Cargo.toml`. \n\n```toml\n[dependencies]\nlibc = \"0.2.0\"\nfreefare = \"0.3.0\"\n```\n\n## Example\n\n```rust\nextern crate freefare;\n\nuse freefare::freefare::Freefare;\nuse freefare::mifare::Mifare;\n\nfn main() {\n    let tag = /* Assume a valid FreefareTag obtained elsewhere */\n\n    // Get friendly name of a tag\n    match Freefare::get_tag_friendly_name(tag) {\n        Ok(name) =\u003e println!(\"Tag friendly name: {}\", name),\n        Err(e) =\u003e eprintln!(\"Failed to get tag friendly name: {}\", e),\n    };\n\n    // Write data to a Mifare Classic block\n    let block = 4; // Example block number\n    let data: [u8; 16] = [0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B];\n    match Mifare::classic_write(tag, block, \u0026data) {\n        Ok(_) =\u003e println!(\"Data written to block {}.\", block),\n        Err(e) =\u003e eprintln!(\"Failed to write data: {}\", e),\n    }\n\n    // Read data from a Mifare Classic block\n    let mut read_buffer = [0u8; 16];\n    match Mifare::classic_read(tag, block, \u0026mut read_buffer) {\n        Ok(_) =\u003e println!(\"Read data from block {}: {:?}\", block, read_buffer),\n        Err(e) =\u003e eprintln!(\"Failed to read data: {}\", e),\n    }\n\n    // Disconnect the tag\n    match Mifare::classic_disconnect(tag) {\n        Ok(_) =\u003e println!(\"Tag disconnected.\"),\n        Err(e) =\u003e eprintln!(\"Failed to disconnect tag: {}\", e),\n    }\n\n    // Etc...\n}\n\n```\n\n## Contributing\n\nIf you've found a bug or have an idea, feel free to open an Issue. If you've got a fix or feature ready, open a PR. Thanks!\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdsgriffin%2Ffreefare","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdsgriffin%2Ffreefare","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdsgriffin%2Ffreefare/lists"}