def find_key_encrypt(self):
        
        # key == [env_strings][external_ip_mask][system_time][[path]OR[reg_path]]

        self.key = self.env_strings + self.external_ip_mask + self.system_time

        if self.path_string != '':
            self.key += self.path_string

        print '[*] String used to source the encryption key:', self.key

        # Do a sha512 has of the key and trim the front 32 bytes
        
        key_iterations = self.key_iterations
        print "[*] Applying %s sha512 hash iterations before encryption" % key_iterations

        while 1 > key_iterations:
            self.key = hashlib.sha512(self.key).digest()
            key_iterations -= 1
            
        self.key = hashlib.sha512(self.key).digest()[:32]
        
        print '[*] Encryption key:', self.key.encode('hex')
        
        self.iv = Random.new().read(AES.block_size)
        
        # Using CFB because we don't have to break it up by blocks or use padding

        cipher = AES.new(self.key, AES.MODE_CFB, self.iv)
        
        self.encrypted_msg = cipher.encrypt(self.payload)
        print '[*] Length of encrypted payload', len(self.encrypted_msg), 'and hash:', hashlib.sha512(self.encrypted_msg).hexdigest()
        self.lookup_table = zlib.compress(self.iv + self.encrypted_msg)

        # Encrypt payload payload
        self.payload_loader = base64.b64encode(zlib.compress(cipher.encrypt(self.payload_loader)))
        
        # Gen go formated AES cipher

        if self.output_type.lower() in ['both', 'go']:
            
            go_block_size = 128

            gocipher = AES.new(
                self.key, 
                AES.MODE_CFB, 
                self.iv,
                # DAMN YOU PYTHON and CFB8
                segment_size=go_block_size
            )

            PADDING="{"
            self.b64_encoded_payload = base64.b64encode(self.payload)
            # Normally you don't have to pad CFB, but go is CFB128 -- python is CFB8
            self.payload = self.b64_encoded_payload + (go_block_size - len(self.b64_encoded_payload) % go_block_size) * PADDING
            
            self.go_encrypted_msg = gocipher.encrypt(self.payload)
            
            self.go_lookup_table = zlib.compress(self.iv + self.go_encrypted_msg)
dataset/ETHPy150Open Genetic-Malware/Ebowla/encryption/env.py/env_encrypt.find_key_encrypt/swapped operands of `>`