Finish challenge 17.

This commit is contained in:
2022-07-05 19:08:25 -04:00
parent 08a8cad6f2
commit 57836c91f1
3 changed files with 76 additions and 37 deletions

View File

@@ -107,10 +107,13 @@ impl Bytes {
}
let last_block_index = self.len() / block_size - 1;
let last_block = self.get_block(last_block_index, block_size).0;
let pad_byte_count = last_block[block_size - 1];
for i in 0..(pad_byte_count as usize) {
let pad_byte = last_block[block_size - 1];
if pad_byte < 1 || pad_byte > 16 {
return false;
}
for i in 0..(pad_byte as usize) {
let byte = last_block[block_size - 1 - i];
if byte != pad_byte_count {
if byte != pad_byte {
return false;
}
}