diff options
Diffstat (limited to 'src/block.rs')
-rw-r--r-- | src/block.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/block.rs b/src/block.rs index e1140e7..2b7907a 100644 --- a/src/block.rs +++ b/src/block.rs @@ -94,6 +94,16 @@ impl Block { result } + /// Pad the block to full length. + /// + /// Unlike [`pad`], this function takes the length in bytes. + pub fn pad_bytes(&self, length: u8) -> Block { + assert!(length <= 15); + let mut result = *self; + result[length as usize] = 0x80; + result + } + /// Clip the block by setting all bits beyond the given length to 0. pub fn clip(&self, length: usize) -> Block { match length { |