some small refactoring

This commit is contained in:
Reid 2023-09-11 20:00:20 -07:00
parent dd7c66a13b
commit e591b11065
Signed by: reidlab
GPG key ID: 6C9EAA3364F962C8
20 changed files with 957 additions and 40 deletions

View file

@ -27,4 +27,24 @@ pub fn decode_gjp(gjp: String) -> String {
let base64_decoded = String::from_utf8(general_purpose::STANDARD.decode(gjp).expect("couldn't decode base64")).expect("invalid UTF-8 sequence (how)");
let xor_decoded = cyclic_xor_string(&base64_decoded, "37526");
return xor_decoded
}
pub fn gen_multi(level_hash_data: Vec<(i32, i32, bool)>) -> String {
let mut input_str = String::new();
for (_index, val) in level_hash_data.iter().enumerate() {
let (level_id, stars, coins) = val;
let level_id_str = level_id.to_string();
input_str.push(level_id_str.chars().nth(0).unwrap());
input_str.push(level_id_str.chars().last().unwrap());
input_str.push_str(&stars.to_string());
input_str.push_str(if *coins { "1" } else { "0" });
}
let mut bytes: Vec<u8> = Vec::new();
bytes.extend(input_str.as_bytes().to_vec());
bytes.extend("xI25fpAapCQg".as_bytes().to_vec());
return Sha1::default().digest(bytes.as_mut_slice()).to_hex();
}