Created
April 20, 2020 11:46
-
-
Save PaburoTC/ec355d409eab6b0cb2373b2c7c88174e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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