please look at this code first -> use aes::Aes256; use blockmodes::blockpadding::Pkcs7;…
- User
please look at this code first -> 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> { 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();
code - Assistant
- User
ok then, how to speed up this code a bit and utilize multicore and multi CPU programming ? which crates to use or something else ? show me the code as well .
- Assistant