merge stable version #2
|
@ -5,6 +5,17 @@ use crate::{
|
||||||
model::models::*,
|
model::models::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static SYNDROMES: LazyLock<HashMap<usize, (bool, bool, bool)>> = LazyLock::new(|| {
|
||||||
|
HashMap::from([
|
||||||
|
(1, (false, true, true)),
|
||||||
|
(2, (false, false, true)),
|
||||||
|
(3, (true, false, true)),
|
||||||
|
(4, (false, true, false)),
|
||||||
|
(5, (true, true, false)),
|
||||||
|
(6, (true, false, false)),
|
||||||
|
(7, (false, false, false)),
|
||||||
|
])
|
||||||
|
});
|
||||||
|
|
||||||
pub fn hamming(raw_input: String, mode: HammingMode) -> Result<String, String> {
|
pub fn hamming(raw_input: String, mode: HammingMode) -> Result<String, String> {
|
||||||
let length_of_code: usize = mode.clone() as usize;
|
let length_of_code: usize = mode.clone() as usize;
|
||||||
|
@ -51,15 +62,6 @@ pub fn hamming_encrypt_data(data: &Vec<u8>, result_string: &mut String, length_o
|
||||||
pub fn hamming_decrypt_data(data: &Vec<u8>, result_string: &mut String, length_of_code: usize) {
|
pub fn hamming_decrypt_data(data: &Vec<u8>, result_string: &mut String, length_of_code: usize) {
|
||||||
let mut general_length: usize = length_of_code;
|
let mut general_length: usize = length_of_code;
|
||||||
|
|
||||||
let syndromes: HashMap<usize, (bool, bool, bool)> = HashMap::from([
|
|
||||||
(1, (false, true, true)),
|
|
||||||
(2, (false, false, true)),
|
|
||||||
(3, (true, false, true)),
|
|
||||||
(4, (false, true, false)),
|
|
||||||
(5, (true, true, false)),
|
|
||||||
(6, (true, false, false)),
|
|
||||||
(7, (false, false, false)),
|
|
||||||
]);
|
|
||||||
|
|
||||||
let mut errors: String = String::new();
|
let mut errors: String = String::new();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue