Add base62 encoding

This commit is contained in:
Michael Mikovsky
2025-11-10 22:18:21 -07:00
parent 0881e46a17
commit 2b5074153b
21 changed files with 981 additions and 134 deletions
+74 -13
View File
@@ -13,6 +13,15 @@ dependencies = [
"cpufeatures",
]
[[package]]
name = "aho-corasick"
version = "1.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301"
dependencies = [
"memchr",
]
[[package]]
name = "android_system_properties"
version = "0.1.5"
@@ -279,6 +288,12 @@ version = "0.4.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432"
[[package]]
name = "memchr"
version = "2.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273"
[[package]]
name = "num-traits"
version = "0.2.19"
@@ -318,6 +333,35 @@ version = "5.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
[[package]]
name = "regex"
version = "1.12.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4"
dependencies = [
"aho-corasick",
"memchr",
"regex-automata",
"regex-syntax",
]
[[package]]
name = "regex-automata"
version = "0.4.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.8.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58"
[[package]]
name = "rustversion"
version = "1.0.22"
@@ -372,9 +416,9 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
[[package]]
name = "syn"
version = "2.0.109"
version = "2.0.110"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f17c7e013e88258aa9543dcbe81aca68a667a9ac37cd69c9fbc07858bfe0e2f"
checksum = "a99801b5bd34ede4cf3fc688c5919368fea4e4814a4664359503e6015b280aea"
dependencies = [
"proc-macro2",
"quote",
@@ -397,21 +441,13 @@ checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5"
name = "unshell-cli"
version = "0.1.0"
dependencies = [
"unshell-crypt",
"unshell-lib",
]
[[package]]
name = "unshell-lib"
version = "0.1.0"
dependencies = [
"bincode",
"chrono",
"libloading",
"unshell-obfuscate",
]
[[package]]
name = "unshell-obfuscate"
name = "unshell-crypt"
version = "0.1.0"
dependencies = [
"aes",
@@ -420,10 +456,35 @@ dependencies = [
"getrandom",
"hex",
"hex-literal",
"regex",
"sha2",
]
[[package]]
name = "unshell-lib"
version = "0.0.0"
dependencies = [
"aes",
"bincode",
"block-padding 0.4.1",
"cbc",
"chrono",
"getrandom",
"hex",
"hex-literal",
"libloading",
"sha2",
"unshell-obfuscate",
]
[[package]]
name = "unshell-obfuscate"
version = "0.0.0"
dependencies = [
"proc-macro2",
"quote",
"sha2",
"syn",
"unshell-crypt",
]
[[package]]
+3 -1
View File
@@ -4,4 +4,6 @@ version = "0.1.0"
edition = "2024"
[dependencies]
unshell-lib = {path = "../unshell-lib"}#, default-features = false, features = ["server-component"]}
unshell-lib = {path = "../unshell-lib"}
unshell-obfuscate = {path = "../unshell-obfuscate"}
unshell-crypt = {path = "../unshell-crypt"}
+77 -6
View File
@@ -1,14 +1,82 @@
use std::io::{Write, stdin, stdout};
use unshell_crypt::{
aes::{decrypt_aes, decrypt_aes_lines, encrypt_aes, encrypt_aes_lines},
base62::Base62,
fill, hash,
};
use unshell_lib::Announcement;
// use unshell_test_module::ListenerRuntime;
use unshell_obfuscate::format_obs;
// fn print_continue_prompt(str: &str) {
// printl
// }
fn main() -> Result<(), Box<dyn std::error::Error>> {
// let aaa = unshell_lib::crypt::aes::decrypt_aes(
// "611dcb046fcb11c3a0cf6d27ac7c8452e0120c2675d067a0dd857d9cd3d9df21140f1e2a715083a48180907eb90b87a6", //_1c82a871dda0f4372eb8e0dbba34c8de",
// "abc123abc",
// )?;
let key = "abc123abc";
println!(
"{}",
encrypt_aes_lines("Verylongstringthat1", &key, unshell_crypt::STATIC_IV)
);
println!(
"{}",
encrypt_aes_lines("Verylongstringthat12", &key, unshell_crypt::STATIC_IV)
);
println!(
"{}",
encrypt_aes_lines("Verylongstringthat123", &key, unshell_crypt::STATIC_IV)
);
println!(
"{}",
encrypt_aes_lines("Verylongstringthat1234", &key, unshell_crypt::STATIC_IV)
);
println!(
"{}",
encrypt_aes_lines("Verylongstringthat12345", &key, unshell_crypt::STATIC_IV)
);
// let e = Base62::encode_full(data, &key);
// let e = "_Nl8MlCFOyM4egPSXfo0wE4tfA0vOfBSZCx1TpKzjhI2qfahTrwh4JE1pJpcBttQqz_";
// let mut buf = [0u8; 256];
// _L1IuRLMW8tZN68RerKcbltQl675Yeq930NbcxsEfYYf_
// _L1IuRLMW8tZN68RerKcblyGtqOCLeLuBu3ormgklt3J_
// _L1IuRLMW8tZN68RerKcblKi37HPcZRonvwFUS5SZc0C_
// _L1IuRLMW8tZN68RerKcblya0Yw6TrFQxruqpemtv3K2_
// fill(&mut buf);
// for byte in buf.iter() {
// print!("{}, ", byte);
// }
// src/main.rs:13
// _SqF7lDRCyatsM4hnUTNAOq_
//
// _Nl8MlCFOyM4egPSXfo0wE4tfA0vOfBSZCx1TpKzjhI2qfahTrwh4JE1pJpcBttQqz_
// unshell-lib-0.0.0/src/module/manager.rs:52
// println!("Key: {}", String::from_utf8_lossy(&key));
// let encoded = Base62::decode_full(&e, &key).unwrap();
// let plaintext = decrypt_aes_lines(&data, &key, unshell_crypt::STATIC_IV);
// let base = Base62::new(&hash("TEST_KEY".as_bytes()), 0);
// let encoded = base.encode("123 1234 12342 1235e2".as_bytes());
// println!("Base62: {}", plaintext);
// let base = Base62::new(&hash("TEST_KEY".as_bytes()), 0);
// let decoded = base.decode(&encoded).unwrap();
// println!("Decoded: {}", String::from_utf8(decoded).unwrap());
// Ok(())
fn main() {
let mut serverruntime = unshell_lib::server::ListenerRuntime::new();
loop {
@@ -16,6 +84,9 @@ fn main() {
stdout().flush().expect("Failed to flush stdout");
let mut input = String::new();
stdin().read_line(&mut input).expect("Failed to read line");
// println!("{}", input);
let args = input.trim().split(" ").collect::<Vec<&str>>();
match args[0] {
@@ -35,6 +106,6 @@ fn main() {
}
}
// println!("{:?}", args);
println!("{:?}", args);
}
}