fn prepare_key<D: Digest>(key: &[u8]) -> Vec<u8> {
    // TODO Somehow use <D as BlockInput>::BlockSize to obtain
    // the actual block size.
    let block_size = 64;
    let mut key = if key.len() > block_size {
        D::digest(key).to_vec()
    } else {
        key.to_vec()
    };

    while key.len() < block_size {
        key.push(0);
    }
    key
}
// This function assumes that the block size of D is 64.
// This is correct for SHA-1 and SHA-256.
This function assumes that the block size of D is 64.
This is correct for SHA-1 and SHA-256.
This function assumes that the block size of D is 64 . This is correct for SHA - 1 and SHA - 256 .
fn prepare_key<D: Digest>(key: &[u8]) -> Vec<u8> {
    // TODO Somehow use <D as BlockInput>::BlockSize to obtain
    // the actual block size.
    let block_size = 64;
    let mut key = if key.len() > block_size {
        D::digest(key).to_vec()
    } else {
        key.to_vec()
    };
    while key.len() < block_size {
        key.push(0);
    }
    key
}
fn prepare_key < D : Digest > ( key : & [ u8 ] ) -> Vec < u8 > { // TODO Somehow use <D as BlockInput>::BlockSize to obtain // the actual block size. let block_size = 64 ; let mut key = if key . len ( ) > block_size { D :: digest ( key ) . to_vec ( ) } else { key . to_vec ( ) } ; while key . len ( ) < block_size { key . push ( 0 ) ; } key }
This function assumes that the block size of D is 64.
This function assumes that the block size of D is 64 .
key
&[u8]
key
&[u8]