use aes::cipher::{Array, KeyIvInit, StreamCipher};
use byteorder::{BigEndian, ReadBytesExt};
use std::io::Cursor;
type Aes256Ctr32BE = ctr::Ctr32BE<aes::Aes256>;
const MAX_VALUE: u32 = 2_147_483_648;
fn generate() -> String {
let mut table = [0u8; 1024];
let key = Array::from([0u8; 32]);
let nonce = Array::from([0u8; 16]);
let mut cipher = Aes256Ctr32BE::new(&key, &nonce);
cipher.apply_keystream(&mut table);
let mut result = String::new();
result.push_str("const TABLE: [u32; 256] = [\n");
let mut rdr = Cursor::new(&table[..]);
for index in 1..257 {
let mut num: u32 = rdr.read_u32::<BigEndian>().unwrap();
num %= MAX_VALUE;
result.push_str(&format!(" {:#010x},", num));
if index % 8 == 0 {
result.push('\n');
}
}
result.truncate(result.len() - 2);
result.push_str("\n];\n");
result
}
fn main() {
let table = generate();
println!("{}", table);
}