version 1.1.0 adds playing card and friendship bracelet passwords
parent
38bda54e97
commit
0cf3f54ee8
|
|
@ -42,7 +42,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "division_of_one"
|
name = "division_of_one"
|
||||||
version = "1.0.2"
|
version = "1.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rand",
|
"rand",
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ keywords = ["passphrase", "password"]
|
||||||
license = "AGPL-3.0"
|
license = "AGPL-3.0"
|
||||||
name = "division_of_one"
|
name = "division_of_one"
|
||||||
repository = "https://six-five-six-four.com/git/reactor/division_of_one"
|
repository = "https://six-five-six-four.com/git/reactor/division_of_one"
|
||||||
version = "1.0.2"
|
version = "1.1.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rand = { version = "0.10.0", features = ["unbiased"] }
|
rand = { version = "0.10.0", features = ["unbiased"] }
|
||||||
|
|
|
||||||
23
src/lib.rs
23
src/lib.rs
|
|
@ -1,8 +1,15 @@
|
||||||
use rand::{RngExt as _, seq::IndexedRandom as _};
|
use rand::{RngExt as _, seq::IndexedRandom as _};
|
||||||
|
|
||||||
|
const ALPHABET: &str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||||
|
const CARD_VALUES: &str = "A234567890JQK";
|
||||||
|
|
||||||
pub fn main() -> Result<(), String> {
|
pub fn main() -> Result<(), String> {
|
||||||
let mut args = std::env::args();
|
let mut args = std::env::args();
|
||||||
|
|
||||||
|
// Ignore the exe name
|
||||||
let _ = args.next();
|
let _ = args.next();
|
||||||
|
|
||||||
|
// Read the first arg as a command or flag
|
||||||
match args.next().as_deref() {
|
match args.next().as_deref() {
|
||||||
None => {}
|
None => {}
|
||||||
Some("--version") => {
|
Some("--version") => {
|
||||||
|
|
@ -16,6 +23,14 @@ pub fn main() -> Result<(), String> {
|
||||||
println!("{}", create_pin(9));
|
println!("{}", create_pin(9));
|
||||||
println!("{}", create_base32(8));
|
println!("{}", create_base32(8));
|
||||||
|
|
||||||
|
// Shuffling all 26 letters allows you to store 88 bits of information on beads on a bracelet. Destroying the bracelet doesn't reveal any information if all 26 letters are used.
|
||||||
|
println!("{}", create_shuffle(ALPHABET));
|
||||||
|
|
||||||
|
// Shuffling all 13 values of a suit of playing cards allow you to store 32.5 bits of information. A standard deck of cards can hold 130 bits of entropy ignoring suits. Mixing up the cards provably destroys the information.
|
||||||
|
for _ in 0..4 {
|
||||||
|
println!("{}", create_shuffle(CARD_VALUES));
|
||||||
|
}
|
||||||
|
|
||||||
// Read a line of input so that the CLI can run in its own terminal without instantly closing the terminal when we exit.
|
// Read a line of input so that the CLI can run in its own terminal without instantly closing the terminal when we exit.
|
||||||
println!("Press Enter");
|
println!("Press Enter");
|
||||||
let mut input = String::new();
|
let mut input = String::new();
|
||||||
|
|
@ -56,6 +71,14 @@ pub fn create_pin(len: usize) -> String {
|
||||||
digits.join("")
|
digits.join("")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn create_shuffle(input: &str) -> String {
|
||||||
|
use rand::prelude::SliceRandom;
|
||||||
|
|
||||||
|
let mut input: Vec<char> = input.chars().collect();
|
||||||
|
input.shuffle(&mut rand::rng());
|
||||||
|
String::from_iter(input.iter())
|
||||||
|
}
|
||||||
|
|
||||||
pub struct Dice {
|
pub struct Dice {
|
||||||
words: Vec<String>,
|
words: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue