tlslite/utils/pycrypto_aes.py
Similar blocks of code found in 2 locations. Consider refactoring.# Author: Trevor PerrinSimilar blocks of code found in 2 locations. Consider refactoring.# See the LICENSE file for legal information regarding use of this file.Similar blocks of code found in 2 locations. Consider refactoring. Similar blocks of code found in 2 locations. Consider refactoring."""PyCrypto AES implementation."""Similar blocks of code found in 2 locations. Consider refactoring. Similar blocks of code found in 2 locations. Consider refactoring.from .cryptomath import *Similar blocks of code found in 2 locations. Consider refactoring.from .aes import *Similar blocks of code found in 2 locations. Consider refactoring. Similar blocks of code found in 2 locations. Consider refactoring.if pycryptoLoaded:Similar blocks of code found in 2 locations. Consider refactoring. import Crypto.Cipher.AESSimilar blocks of code found in 2 locations. Consider refactoring. Similar blocks of code found in 2 locations. Consider refactoring. def new(key, mode, IV):Similar blocks of code found in 2 locations. Consider refactoring. return PyCrypto_AES(key, mode, IV)Similar blocks of code found in 2 locations. Consider refactoring. Similar blocks of code found in 2 locations. Consider refactoring. class PyCrypto_AES(AES):Similar blocks of code found in 2 locations. Consider refactoring. Similar blocks of code found in 2 locations. Consider refactoring. def __init__(self, key, mode, IV):Similar blocks of code found in 2 locations. Consider refactoring. AES.__init__(self, key, mode, IV, "pycrypto")Similar blocks of code found in 2 locations. Consider refactoring. key = bytes(key)Similar blocks of code found in 2 locations. Consider refactoring. IV = bytes(IV)Similar blocks of code found in 2 locations. Consider refactoring. self.context = Crypto.Cipher.AES.new(key, mode, IV)Similar blocks of code found in 2 locations. Consider refactoring. Similar blocks of code found in 2 locations. Consider refactoring. def encrypt(self, plaintext):Similar blocks of code found in 2 locations. Consider refactoring. plaintext = bytes(plaintext)Similar blocks of code found in 2 locations. Consider refactoring. return bytearray(self.context.encrypt(plaintext))Similar blocks of code found in 2 locations. Consider refactoring. Similar blocks of code found in 2 locations. Consider refactoring. def decrypt(self, ciphertext):Similar blocks of code found in 2 locations. Consider refactoring. ciphertext = bytes(ciphertext)Similar blocks of code found in 2 locations. Consider refactoring. return bytearray(self.context.decrypt(ciphertext))