cryptoy 0.4.0

Toy implementations of cryptographic protocols for educational purposes
Documentation
/// Extends a slice to the appropriate size of Vec, padding extra length with 0s.
///
/// Suitable for use in little-endian byte ordering.
pub fn right_pad_0s(bytes: &[u8], length: usize) -> Vec<u8> {
    let mut padded = vec![0_u8; length];
    padded[..bytes.len()].copy_from_slice(bytes);
    padded
}

/// Extends a slice to the appropriate size of Vec, padding extra length with 0s.
///
/// Suitable for use in big-endian byte ordering.
pub fn left_pad_0s(bytes: &[u8], length: usize) -> Vec<u8> {
    if length <= bytes.len() {
        return bytes.to_vec();
    }
    let init_cap = length - bytes.len();
    //println!("init_cap: {}, length: {}, bytes.len(): {}", init_cap, length, bytes.len());
    let mut padded = vec![0_u8; init_cap];
    padded.extend(bytes.iter());
    padded
}