https://github.com/davidk/wifiqr
A rustlang crate & utility to generate scannable QR codes for Wifi access
https://github.com/davidk/wifiqr
qr-codes rust rust-crate wifi
Last synced: about 1 month ago
JSON representation
A rustlang crate & utility to generate scannable QR codes for Wifi access
- Host: GitHub
- URL: https://github.com/davidk/wifiqr
- Owner: davidk
- License: mit
- Created: 2019-07-31T00:54:35.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2022-07-09T23:29:43.000Z (almost 3 years ago)
- Last Synced: 2025-04-14T05:38:51.596Z (about 1 month ago)
- Topics: qr-codes, rust, rust-crate, wifi
- Language: Rust
- Homepage:
- Size: 1.5 MB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# WifiQr
This Rust crate encodes Wifi credentials into a QR code. A [command-line interface](https://github.com/davidk/WifiQr/releases) is available for testing and basic use, too.
### Releases
To use WifiQr's command-line implementation, download a pre-built binary from the [releases tab](https://github.com/davidk/WifiQr/releases).
### Utility usage
USAGE:
wifiqr [ --ssid (ssid) ] [ --password (password) | --ask ]
[ --encr encryption type (default:wpa2) ]
[ --imagefile (output_name.png) | --svg | --svgfile (output_name.svg) ]
FLAGS:
--hidden Optional: Indicate whether or not the SSID is hidden
--svg Emit the QR code as an SVG (to standard output)
--console Print the QR code out to the console
-d, --debug Display some extra debugging output
-a, --ask Ask for password instead of getting it through the command-line
--ask-echo Ask for password while displaying input on the console
--quote If the SSID or password could be mistaken for a hexadecimal value,
this option will add double-quotes around the SSID and password
-h, --help Prints help information
-V, --version Prints version information
OPTIONS:
--ssid Sets the WiFi SSID
--password Sets the WiFi password [default: ]
--encr The WiFi's encryption type (wpa, wpa2, nopass) [default: wpa2]
--scale QR code scaling factor [default: 10]
--quietzone QR code: The size of the quiet zone/border to apply to the final QR code [default:
2]
--imagefile The name of the file to save to (e.g. --imagefile qr.png). Formats: [png, jpg, bmp]
--svgfile Save the QR code to a file (SVG formatted)### Crate
This crate is available on [crates.io](https://crates.io/crates/wifiqr). Please be sure to pin the version you're using to a specific release (or commit), to avoid any changes that may break your application (efforts will be made to ensure that this is not the case).
```rust
extern crate wifiqr;fn main() {
let quiet_zone = 5;
let config = wifiqr::code::auth(
Some("ssid"), // Network name (ssid)
Some("password"), // Network password/passphrase
Some("wpa2"), // WPA | WPA2 | WEP
false, // Hidden SSID (true | false)
false, // SSID needs to be quoted (true | false)
);let encoding = wifiqr::code::encode(&config).expect("There was a problem generating the QR code");
// this passes the svg output from the QR encoder back
println!("{}", wifiqr::code::make_svg(&encoding));// this prints a qr code to the console
wifiqr::code::console_qr(&encoding, quiet_zone);
}```
#### Building
Pre-built releases are provided on GitHub, but for development, or to build your own from source (after installing the [Rust toolchain](https://www.rust-lang.org/tools/install):
cargo build --release
### Information on QR codes as used in WI-FI authentication
* [Format documentation, from zxing/zxing](https://github.com/zxing/zxing/wiki/Barcode-Contents)
### Crates Used
* [qrcodegen, via project nayuki](https://docs.rs/crate/qrcodegen/1.4.0)