#wifi #wpa #password #hash

wpa-psk

Compute the WPA-PSK of a Wi-FI SSID and passphrase

9 releases

0.2.2 Mar 14, 2023
0.2.1 Feb 16, 2023
0.2.0 May 28, 2022
0.1.5 May 23, 2022
0.1.0 Jan 3, 2022

#460 in Algorithms

Download history 12/week @ 2023-02-06 49/week @ 2023-02-13 37/week @ 2023-02-20 20/week @ 2023-02-27 7/week @ 2023-03-06 27/week @ 2023-03-13 3/week @ 2023-03-20 5/week @ 2023-03-27 21/week @ 2023-04-03 24/week @ 2023-04-10 20/week @ 2023-04-17 14/week @ 2023-04-24 17/week @ 2023-05-01 32/week @ 2023-05-08 31/week @ 2023-05-15 13/week @ 2023-05-22

100 downloads per month
Used in wpa-psk-cli

MIT/Apache

8KB
124 lines

wpa-psk

This is a Rust library to compute the WPA pre-shared key of a Wi-Fi SSID and passphrase. See also the corresponding command-line interface wpa-psk-cli.

See the crate documentation for more information.

License

This work is distributed under the terms of both, the MIT License and the Apache License, Version 2.0.

Contribution

Contributions are welcome! Please contact me via email.


lib.rs:

Compute the WPA-PSK of a Wi-Fi SSID and passphrase.

Example

Compute and print the WPA-PSK of a valid SSID and passphrase:

# use wpa_psk::{Ssid, Passphrase, wpa_psk, bytes_to_hex};
# fn main() -> Result<(), Box<dyn std::error::Error>> {
let ssid = Ssid::try_from("home")?;
let passphrase = Passphrase::try_from("0123-4567-89")?;
let psk = wpa_psk(&ssid, &passphrase);
assert_eq!(bytes_to_hex(&psk), "150c047b6fad724512a17fa431687048ee503d14c1ea87681d4f241beb04f5ee");
# Ok(())
# }

Compute the WPA-PSK of possibly invalid raw bytes:

# use wpa_psk::{wpa_psk_unchecked, bytes_to_hex};
let ssid = "bar".as_bytes();
let passphrase = "2short".as_bytes();
let psk = wpa_psk_unchecked(&ssid, &passphrase);
assert_eq!(bytes_to_hex(&psk), "cb5de4e4d23b2ab0bf5b9ba0fe8132c1e2af3bb52298ec801af8ad520cea3437");

Dependencies

~420KB