// Strips padding added by pad(). Returns None if the block has
// invalid padding.
Strips padding added by pad(). Returns None if the block has
invalid padding.
Strips padding added by pad () . Returns None if the block has invalid padding .
pub fn remove_padding(mut msg: Vec<u8>) -> Option<Vec<u8>> {
    // Check for empty messages.
    if msg.len() == 0 {
        return None;
    }
    // Get the last byte and verify that it is not larger than the
    // the message.
    let pad_bytes = *msg.last().unwrap();
    if pad_bytes as usize > msg.len() {
        return None;
    }
    // Remove and validate the pad bytes.
    for _ in 0..pad_bytes {
        match msg.pop() {
            Some(v) if v == pad_bytes => continue,
            _ => return None
        }
    }
    Some(msg)
}
pub fn remove_padding ( mut msg : Vec < u8 > ) -> Option < Vec < u8 > > { // Check for empty messages. if msg . len ( ) == 0 { return None ; } // Get the last byte and verify that it is not larger than the // the message. let pad_bytes = * msg . last ( ) . unwrap ( ) ; if pad_bytes as usize > msg . len ( ) { return None ; } // Remove and validate the pad bytes. for _ in 0 .. pad_bytes { match msg . pop ( ) { Some ( v ) if v == pad_bytes => continue , _ => return None } } Some ( msg ) }
Strips padding added by pad().
Strips padding added by pad () .
msg
Vec<u8>