fn pad_data(inp: &[u8]) -> Vec<[Wrapping<u32>; 16]> {
    let inp_len_bits = inp.len() * 8;
                     // Divide size of input data by
                     // size of a single block
                     //
                     // max function used because if length of
                     // input is zero, then there still needs to be
                     // one block
    let num_blocks = max(((inp_len_bits as f32 / 512_f32).ceil()
                     // If there is not enough space
                     // left in a block to insert a '1' bit
                     // and the 64 bit number representing
                     // the size of the input data,
                     // then add one more block.
                   + ((inp_len_bits % 512) as f32 / 448_f32).floor()) as usize, 1);

    let mut blocks = vec![[Wrapping(0_u32); 16]; num_blocks];

    let mut block_num = 0;
    let mut block_pos = 0;

    for (i, x) in inp.iter().enumerate() {
        // Current block
        block_num = (i as f32 / 64_f32).floor() as usize;
        // Current position in block
        block_pos = ((i % 64) as f32 / 4_f32).floor() as usize;

        // Big Endian implementation, fill up empty u32 elements
        // by ORing it with four u8 elements starting from
        // left to right.
        blocks[block_num][block_pos].0 |= (*x as u32) << 24 - (i % 4 * 8);
    }

    // Which u32 segment the '1' bit should occupy after
    // the last u8 input byte
    let next_input = inp.len() % 4;

    if next_input == 0 && inp.len() > 0 {
        if block_pos == 15 {
            block_pos = 0;
            block_num = 0;
        } else {
            block_pos += 1;
        }
    }

    // Set most significant bit (which is the bit neighboring
    // the last input byte) to '1'
    blocks[block_num][block_pos].0 |= 128_u32 << 24 - next_input * 8;

    // Fill end of last block with 64 bit number representing
    // size of input data in bits
    let blocks_len = blocks.len();
    blocks[blocks_len - 1][15].0 = inp_len_bits as u32;
    blocks[blocks_len - 1][14].0 = (inp_len_bits >> 32) as u32;

    blocks
}
// Converts u8 slice into a vector of 512 bit 
// blocks, represented as u32 arrays with 
// length 16
Converts u8 slice into a vector of 512 bit
blocks, represented as u32 arrays with
length 16
Converts u8 slice into a vector of 512 bit blocks represented as u32 arrays with length 16
fn pad_data(inp: &[u8]) -> Vec<[Wrapping<u32>; 16]> {
    let inp_len_bits = inp.len() * 8;
                     // Divide size of input data by
                     // size of a single block
                     //
                     // max function used because if length of
                     // input is zero, then there still needs to be
                     // one block
    let num_blocks = max(((inp_len_bits as f32 / 512_f32).ceil()
                     // If there is not enough space
                     // left in a block to insert a '1' bit
                     // and the 64 bit number representing
                     // the size of the input data,
                     // then add one more block.
                   + ((inp_len_bits % 512) as f32 / 448_f32).floor()) as usize, 1);
    let mut blocks = vec![[Wrapping(0_u32); 16]; num_blocks];
    let mut block_num = 0;
    let mut block_pos = 0;
    for (i, x) in inp.iter().enumerate() {
        // Current block
        block_num = (i as f32 / 64_f32).floor() as usize;
        // Current position in block
        block_pos = ((i % 64) as f32 / 4_f32).floor() as usize;
        // Big Endian implementation, fill up empty u32 elements
        // by ORing it with four u8 elements starting from
        // left to right.
        blocks[block_num][block_pos].0 |= (*x as u32) << 24 - (i % 4 * 8);
    }
    // Which u32 segment the '1' bit should occupy after
    // the last u8 input byte
    let next_input = inp.len() % 4;
    if next_input == 0 && inp.len() > 0 {
        if block_pos == 15 {
            block_pos = 0;
            block_num = 0;
        } else {
            block_pos += 1;
        }
    }
    // Set most significant bit (which is the bit neighboring
    // the last input byte) to '1'
    blocks[block_num][block_pos].0 |= 128_u32 << 24 - next_input * 8;
    // Fill end of last block with 64 bit number representing
    // size of input data in bits
    let blocks_len = blocks.len();
    blocks[blocks_len - 1][15].0 = inp_len_bits as u32;
    blocks[blocks_len - 1][14].0 = (inp_len_bits >> 32) as u32;
    blocks
}
fn pad_data ( inp : & [ u8 ] ) -> Vec < [ Wrapping < u32 > ; 16 ] > { let inp_len_bits = inp . len ( ) * 8 ; // Divide size of input data by // size of a single block // // max function used because if length of // input is zero, then there still needs to be // one block let num_blocks = max ( ( ( inp_len_bits as f32 / 512_f32 ) . ceil ( ) // If there is not enough space // left in a block to insert a '1' bit // and the 64 bit number representing // the size of the input data, // then add one more block. + ( ( inp_len_bits % 512 ) as f32 / 448_f32 ) . floor ( ) ) as usize , 1 ) ; let mut blocks = vec ! [ [ Wrapping ( 0_u32 ) 16 ] num_blocks ] ; let mut block_num = 0 ; let mut block_pos = 0 ; for ( i , x ) in inp . iter ( ) . enumerate ( ) { // Current block block_num = ( i as f32 / 64_f32 ) . floor ( ) as usize ; // Current position in block block_pos = ( ( i % 64 ) as f32 / 4_f32 ) . floor ( ) as usize ; // Big Endian implementation, fill up empty u32 elements // by ORing it with four u8 elements starting from // left to right. blocks [ block_num ] [ block_pos ] . 0 |= ( * x as u32 ) << 24 - ( i % 4 * 8 ) ; } // Which u32 segment the '1' bit should occupy after // the last u8 input byte let next_input = inp . len ( ) % 4 ; if next_input == 0 && inp . len ( ) > 0 { if block_pos == 15 { block_pos = 0 ; block_num = 0 ; } else { block_pos += 1 ; } } // Set most significant bit (which is the bit neighboring // the last input byte) to '1' blocks [ block_num ] [ block_pos ] . 0 |= 128_u32 << 24 - next_input * 8 ; // Fill end of last block with 64 bit number representing // size of input data in bits let blocks_len = blocks . len ( ) ; blocks [ blocks_len - 1 ] [ 15 ] . 0 = inp_len_bits as u32 ; blocks [ blocks_len - 1 ] [ 14 ] . 0 = ( inp_len_bits >> 32 ) as u32 ; blocks }
Converts u8 slice into a vector of 512 bit
blocks, represented as u32 arrays with
length 16
Converts u8 slice into a vector of 512 bit blocks represented as u32 arrays with length 16
inp
&[u8]
inp
&[u8]