1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
//! Passhrase is a pure Rust library focused on generating solid passphrases at the touch of a button //! , giving users the ability to generate memorable strong passphrases that takes thousands of //! years to crack using specialized password cracking computers or taking forever for normal //! computers to crack. //! //!At the moment(an English only version is coming soon), //! it combines English and Swahili dictionaries of short easy to type words. //! The `zxcvbn` crate, a password strength estimator based off of Dropbox's zxcvbn library, //!has been used to counter-check how long it would take to crack the password, //!the number of guesses it would need and the number of years it would take to crack the passphrase. //! //! However, kindly node that this is only a passphrase generator and you need to hash it with //! a good hashing algorithm (I recommend argon2 implementations) for use to store in a database //! //! [WARNING!!!] NEVER STORE THE PLAIN TEXT VERSION OF A PASSPHRASE //! //! --- //! use `cargo add passphrase` to install to add to your `Cargo.toml` file. //! To add it manually to `Cargo.toml` file. //! ``` //! [dependencies] //! passhrase_lib = #enter the version from crates.io here //! ``` //! --- //! Usage: //! ``` //! use passhrase; //! fn main() { //! // Generate a random passphrase //! let random_number = passphrase_lib::gen_passphrase(); //! //! //Generate a random url //! let random_url = passphrase_lib::gen_url(); //! } //! ``` //! //! --- #![forbid(unsafe_code)] mod dictionary; use crate::dictionary::*; use nanorand::{RNG, ChaCha}; fn choose_a_word(data_type: &'static[&'static str]) -> &str { let size = data_type.len(); let data_type = data_type[ChaCha::new(32).generate_range(0, size)]; data_type } pub fn gen_passphrase() -> String { let first_iteration = SWAHILI; let second_iteration = ENGLISH; let third_iteration = SWAHILI; let fourth_iteration = ENGLISH; let passphr = format!("{} {} {} {}", choose_a_word(second_iteration), choose_a_word(first_iteration), choose_a_word(fourth_iteration), choose_a_word(third_iteration)); passphr } pub fn gen_url() -> String { let first_iteration = SWAHILI; let second_iteration = ENGLISH; let fourth_iteration = ENGLISH; let passphr = format!("{}-{}-{}", choose_a_word(second_iteration), choose_a_word(first_iteration), choose_a_word(fourth_iteration)); passphr } pub fn english() -> String { let passphr = format!("{}-{}-{}", choose_a_word(ENGLISH), choose_a_word(ENGLISH), choose_a_word(ENGLISH)); passphr }