Skip to content

Instantly share code, notes, and snippets.

@PaburoTC
Last active April 23, 2020 08:38
Show Gist options
  • Save PaburoTC/7c07ddbde8aafca0774ead2a8da826a2 to your computer and use it in GitHub Desktop.
Save PaburoTC/7c07ddbde8aafca0774ead2a8da826a2 to your computer and use it in GitHub Desktop.
Pad&UnPad
def __pad(self, plain_text):
number_of_bytes_to_pad = self.block_size - len(plain_text) % self.block_size
ascii_string = chr(number_of_bytes_to_pad)
padding_str = number_of_bytes_to_pad * ascii_string
padded_plain_text = plain_text + padding_str
return padded_plain_text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment