0.1.2 adds PIN generation

main v0.1.2
_ 2025-01-25 21:49:17 +00:00
parent dd454dd22b
commit a00d1f3178
4 changed files with 18 additions and 4 deletions

2
Cargo.lock generated
View File

@ -16,7 +16,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "division_of_one"
version = "0.1.0"
version = "0.1.2"
dependencies = [
"rand",
]

View File

@ -7,7 +7,7 @@ keywords = ["passphrase", "password"]
license = "AGPL-3.0"
name = "division_of_one"
repository = "https://six-five-six-four.com/git/reactor/division_of_one"
version = "0.1.1"
version = "0.1.2"
[dependencies]
rand = "0.8.5"

View File

@ -2,11 +2,13 @@
A diceware passphrase generator, e.g. `correct horse battery staple`
Also generates PINs.
Install with `cargo install division_of_one` or download the Windows exe from my Git forge: https://six-five-six-four.com/git/reactor/division_of_one
# Why this and not another generator?
It's easier to write 40 lines of Rust than to audit it.
It's easier to write 50 lines of Rust than to audit it.
I want to just point my friends and family at this without having to check if it's been compromised since the last time I saw it.

View File

@ -1,8 +1,10 @@
use rand::seq::SliceRandom as _;
use rand::{seq::SliceRandom as _, Rng as _};
pub fn main() {
let passphrase = create_passphrase(" ", 8);
println!("{passphrase}");
let pin = create_pin(8);
println!("{pin}");
println!("Press Enter");
let mut input = String::new();
std::io::stdin().read_line(&mut input).ok();
@ -14,6 +16,16 @@ pub fn create_passphrase(separator: &str, len: usize) -> String {
words.join(separator)
}
/// Generates a decimal PIN
///
/// PINs are returned as a String because you do not do math with PINs, therefore they are not numbers.
pub fn create_pin(len: usize) -> String {
let digits: Vec<_> = (0..len)
.map(|_| format!("{}", rand::thread_rng().gen_range(0..=9)))
.collect();
digits.join("")
}
pub struct Dice {
words: Vec<String>,
}