From d9fd0fd29d46b236327b188c52df35e024d84f31 Mon Sep 17 00:00:00 2001 From: _ <_@_> Date: Thu, 16 Dec 2021 20:51:44 +0000 Subject: [PATCH] :construction: wip: working on avalanche idea to make MACs easier for humans to read --- src/avalanche.rs | 40 ++++++++++++++++++++++++++++++++++++++++ src/main.rs | 2 ++ 2 files changed, 42 insertions(+) create mode 100644 src/avalanche.rs diff --git a/src/avalanche.rs b/src/avalanche.rs new file mode 100644 index 0000000..939bfb0 --- /dev/null +++ b/src/avalanche.rs @@ -0,0 +1,40 @@ +type Mac = [u8; 6]; + +pub fn debug () { + for input in [ + [0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 1], + [1, 0, 0, 0, 0, 0], + [1, 0, 0, 0, 0, 1], + ] { + assert_eq! (unmix (mix (input)), input); + } + + println! ("Passed"); +} + +// NOT intended for any cryptography or security. This is TRIVIALLY reversible. +// It's just to make it easier for humans to tell apart MACs where only a couple +// numbers differ. + +fn mix (i: Mac) -> Mac { + [ + i [0] ^ i [5], + i [1] ^ i [4], + i [2] ^ i [3], + i [3], + i [4], + i [5], + ] +} + +fn unmix (i: Mac) -> Mac { + [ + i [0] ^ i [5], + i [1] ^ i [4], + i [2] ^ i [3], + i [3], + i [4], + i [5], + ] +} diff --git a/src/main.rs b/src/main.rs index 2495135..4e63554 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,7 @@ use prelude::*; pub mod app_common; +mod avalanche; mod client; mod ip; pub mod message; @@ -31,6 +32,7 @@ async fn async_main () -> Result <(), AppError> { Some ("--version") => println! ("lookaround v{}", LOOKAROUND_VERSION), Some ("client") => client::client (args).await?, Some ("config") => config (), + Some ("debug-avalanche") => avalanche::debug (), Some ("find-nick") => client::find_nick (args).await?, Some ("my-ips") => my_ips ()?, Some ("server") => server::server (args).await?,