🚧 wip: working on avalanche idea to make MACs easier for humans to read

main
_ 2021-12-16 20:51:44 +00:00
parent f121e3fd55
commit d9fd0fd29d
2 changed files with 42 additions and 0 deletions

40
src/avalanche.rs Normal file
View File

@ -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],
]
}

View File

@ -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?,