summaryrefslogblamecommitdiffstats
path: root/src/main.rs
blob: 5197cbe26f30ec9cf6cf7fcebec36782269136a8 (plain) (tree)
















































                                                                             
fn main()
{
    /* "Compression" setup */
    let raw_file = load_file::load_file_vec(&"data.bin".to_owned()).unwrap();
    let size = raw_file.len();
    let popcnt = vec_pop_cnt(&raw_file);
    let bi_file = BigInt::from_bytes_be(Sign::Plus, &raw_file);
    let solution_hash = demo_hash::hash_bigint(size, &bi_file);

    println!("Length: {}", size);
    print!("SHA512: ");
    demo_hash::show_hash(&solution_hash);
    println!("popcnt: {}", popcnt);

    /*
    //           ,  ,
    for _ in 0..1000000
    {
        bi = iter::next(&bi);
    }

    println!("{:x}", bi);
    panic!("stopping after benchmark");
    */

    //panic!("Performing compress only");

    /* "Decompression" loop */
    let raw = pop_cnt_vec(popcnt);
    let mut bi = BigInt::from_bytes_be(Sign::Plus, &raw);

    loop
    {
        let iteration_hash = demo_hash::hash_bigint(size, &bi);
        //println!("{:b}", bi);
        //println!();

        if iteration_hash == solution_hash
        {
            demo_hash::show_hash(&iteration_hash);
            break;
        }

        bi = iter::next(&bi);
    }

    println!("Found hash (data follows)!!!");
    println!("{:x}", bi);
}