initial commit

This commit is contained in:
pixl_xip 2024-03-30 21:01:04 -06:00
commit 49b23914c1
4 changed files with 117 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/target

75
Cargo.lock generated Normal file
View File

@ -0,0 +1,75 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "getrandom"
version = "0.2.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5"
dependencies = [
"cfg-if",
"libc",
"wasi",
]
[[package]]
name = "keyb-smash"
version = "0.1.0"
dependencies = [
"rand",
]
[[package]]
name = "libc"
version = "0.2.153"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
[[package]]
name = "ppv-lite86"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
[[package]]
name = "rand"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
dependencies = [
"libc",
"rand_chacha",
"rand_core",
]
[[package]]
name = "rand_chacha"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
dependencies = [
"ppv-lite86",
"rand_core",
]
[[package]]
name = "rand_core"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
dependencies = [
"getrandom",
]
[[package]]
name = "wasi"
version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"

9
Cargo.toml Normal file
View File

@ -0,0 +1,9 @@
[package]
name = "keyb-smash"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
rand = "0.8.5"

32
src/main.rs Normal file
View File

@ -0,0 +1,32 @@
use std::env;
use rand::Rng;
fn main() {
let args: Vec<String> = env::args().collect();
let mut rng = rand::thread_rng();
let chars: usize;
if args.len() > 1 {
chars = args[1].parse().expect("Not a valid number!");
} else {
chars = rng.gen_range(20..40);
}
let weighted_char_list = ["a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "s", "s", "s", "s", "s", "s", "s", "s", "s", "s", "s", "s", "s", "s", "s", "d", "d", "d", "d", "d", "d", "d", "d", "d", "d", "d", "d", "d", "d", "d", "d", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "f", "g", "g", "g", "g", "g", "g", "g", "g", "g", "g", "g", "g", "h", "h", "h", "h", "h", "h", "h", "h", "h", "h", "h", "h", "j", "j", "j", "j", "j", "j", "j", "j", "j", "j", "j", "j", "j", "j", "j", "j", "j", "j", "j", "j", "k", "k", "k", "k", "k", "k", "k", "k", "k", "k", "k", "k", "k", "k", "k", "k", "l", "l", "l", "l", "l", "l", "l", "l", "l", "l", "l", "l", "l", "l", "l", ";", ";", ";", ";", ";", ";", ";", ";", ";", ";", ";", ";", "'", "'", "'", "'", "'", "'", "'", "q", "q", "w", "w", "e", "e", "e", "r", "r", "r", "r", "t", "t", "t", "t", "t", "y", "y", "y", "y", "y", "u", "u", "u", "u", "i", "i", "i", "o", "o", "p", "p", "z", "z", "z", "x", "x", "x", "x", "c", "c", "c", "c", "c", "c", "v", "v", "v", "v", "v", "v", "v", "b", "b", "b", "b", "b", "b", "b", "n", "n", "n", "n", "n", "n", "n", "m", "m", "m", "m", "m", "m", ",", ",", ",", ".", ".", "\n"];
let mut shifted = rng.gen_range(0..=1) == 1;
let mut result = String::new();
for _ in 1..=chars {
if rng.gen_range(0..=100) == 0 {
shifted = !shifted;
}
if shifted {
result.push_str(&weighted_char_list[rng.gen_range(0..weighted_char_list.len())].to_uppercase());
} else {
result.push_str(weighted_char_list[rng.gen_range(0..weighted_char_list.len())]);
}
}
println!("{}, {}", result, weighted_char_list.len());
}