please look at this code :    use aes::Aes256;
use block_modes::block_padding::Pkcs7;
use block_modes::{BlockMode, Ecb};
use sha2::{Digest, Sha256};
use std::convert::TryInto;
use std::time::{Duration, Instant};
use std::{fs, io, thread};

type Aes256Ecb = Ecb<Aes256, Pkcs7>;

//const ENCRYPTED_AES_KEY: &str = "";
// i: 1174012
// j: 1258837
// k: 1477889744044
//const ENCRYPTED_SECRET:  &str = "ef5ebbe8f727c54db9755e1c2ead609a0ffc837c25b9493aeb11c68e7a14710e";
const ENCRYPTED_SECRET:  &str = "ce8f36aa844ab00319bcd4f86460a10d77492c060b2c2a91615f4cd1f2d0702e76b68f1ec0f11d15704ba52c5dacc60018d5ed87368464acd030ce6230efdbff7b18cba72ccaa9455a6fe6021b908dd1";

#[derive(Debug, serde::Serialize, serde::Deserialize)]
struct State {
    i: u64,
    j: u64,
}

fn save_state(state: &State, filename: &str) -> io::Result<()> {
    let state_json = serde_json::to_string(&state)?;
    fs::write(filename, state_json)?;
    Ok(())
}

fn load_state(filename: &str) -> io::Result<Option<State>> {
    if let Ok(state_json) = fs::read_to_string(filename) {
        let state: State = serde_json::from_str(&state_json)?;
        Ok(Some(state))
    } else {
        Ok(None)
    }
}

fn main() -> io::Result<()> {
    // Provided data
    // let enc_secret = hex::decode("ef5ebbe8f727c54db9755e1c2ead609a0ffc837c25b9493aeb11c68e7a14710e").unwrap();
    let enc_secret = hex::decode(ENCRYPTED_SECRET).unwrap();

    const PAUSE_INTERVAL: Duration = Duration::from_secs(15 * 60); // 15 minutes
    const PAUSE_DURATION: Duration = Duration::from_secs(60); // 60 seconds

    let mut next_pause = Instant::now();

    let start_range = 1 << 20; // 2^20
    let end_range = 1 << 21; // 2^21
    let mut i_start = start_range;
    let mut j_start = start_range;

    // Load the state if it exists
    let state_filename = "state.json";
    if let Ok(Some(state)) = load_state(state_filename) {
        i_start = state.i;
        j_start = state.j;
    }

    'outer: for i in i_start..end_range {
        for j in j_start..end_range {
            let k = i * j;
            // Check if product has between 40 and 42 bits (not strictly required in Rust)
            if (k.leading_zeros() as u64) >= (64 - 42) && (k.leading_zeros() as u64) <= (64 - 40) {
                let key_material = k.to_string();
                let mut hasher = Sha256::new();
                hasher.update(key_material.as_bytes());
                let key = hasher.finalize();

                let key_slice: &[u8; 32] = key.as_slice().try_into().unwrap();
                let cipher = Aes256Ecb::new_from_slices(key_slice, Default::default()).unwrap();

                if let Ok(decrypted) = cipher.decrypt_vec(&enc_secret) {
                    println!("Key1: {}, Key2: {} --> KEY product {} !", i, j, k);
                    //println!("Dec secret: {:?}", std::str::from_utf8(&decrypted).unwrap());
                    println!("Dec secret: {:?}", String::from_utf8_lossy(&decrypted));

                    if decrypted
                        .windows(b"HTB{".len())
                        .any(|window| window == b"HTB{")
                    {
                        println!("Decryption successful! AES key was found: k={}", k);
                        println!("Decrypted FLAG: {:?}", String::from_utf8_lossy(&decrypted));
                        save_state(&State { i, j }, state_filename)?;
                        break 'outer;
                    }
                }
            }

            if next_pause.elapsed() >= PAUSE_INTERVAL {
                println!("Pausing for a bit to chill the CPU…");
                save_state(&State { i, j }, state_filename)?;
                thread::sleep(PAUSE_DURATION);
                next_pause = Instant::now() + PAUSE_INTERVAL;
            }
        }
        j_start = start_range; // Reset j start for the next iteration of i
    }

    Ok(())
}