Implement challenge 9 pkcs 7 padding.
This commit is contained in:
@@ -67,6 +67,14 @@ impl Bytes {
|
||||
r
|
||||
}
|
||||
|
||||
pub fn pad_pkcs7(&mut self, block_size: usize) -> () {
|
||||
let Bytes(v) = self;
|
||||
let padding_value = (block_size - v.len() % block_size) as u8;
|
||||
for _ in 0..padding_value {
|
||||
v.push(padding_value);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn xor(Bytes(a): &Bytes, Bytes(b): &Bytes) -> Bytes {
|
||||
Bytes(
|
||||
Iterator::zip(a.iter(), b.iter())
|
||||
|
||||
Reference in New Issue
Block a user