Skip to content

Instantly share code, notes, and snippets.

@PaburoTC
Created April 20, 2020 11:46
Show Gist options
  • Save PaburoTC/ec355d409eab6b0cb2373b2c7c88174e to your computer and use it in GitHub Desktop.
Save PaburoTC/ec355d409eab6b0cb2373b2c7c88174e to your computer and use it in GitHub Desktop.
def encrypt(self, plain_text):
plain_text = self.__pad(plain_text)
iv = Random.new().read(self.block_size)
cipher = AES.new(self.key, AES.MODE_CBC, iv)
encrypted_text = cipher.encrypt(plain_text.encode())
return b64encode(iv + encrypted_text).decode("utf-8")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment