tlslite/utils/pycrypto_tripledes.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 3DES 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 .tripledes 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.DES3Similar 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_TripleDES(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_TripleDES(TripleDES):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. TripleDES.__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.DES3.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))