Implement challenge 9 pkcs 7 padding.

This commit is contained in:
2022-04-13 21:42:42 -04:00
parent 415baedd78
commit 766a36e790
3 changed files with 22 additions and 0 deletions

View File

@@ -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())