示例#1
0
 def decode(self, integer_list, key):
     decrypted_integer_list = []
     for integer in integer_list:
         decrypted_integer_list.append(pow(integer, key[1], key[0]))
     decrypted_message = crypto_utils.text_from_blocks(
         decrypted_integer_list, 8)
     return decrypted_message
示例#2
0
 def decode(self, tekst, key):
     decoded_numbers = []
     n = key[0]
     d = key[1]
     for num in tekst:
         decoded_numbers.append(pow(int(num),d,n))
     return cu.text_from_blocks(decoded_numbers,8)
示例#3
0
 def decode(self, coded_text, key):
     decoded = ''
     blokker_decoded = []
     for blokk in coded_text:
         blokker_decoded.append(pow(blokk, key[1], key[0]))
     decoded = text_from_blocks(blokker_decoded, 4)
     return decoded
示例#4
0
文件: rsa.py 项目: stianbm/tdt4113
 def decode(self, text, cipher_key):
     """Decode blocks and use text_from_blocks to fuse them together"""
     decoded_blocks = []
     for block in text:
         decoded_blocks.append(self.decode_int(block, cipher_key))
     return text_from_blocks(decoded_blocks,
                             self._block_length * self._byte_size)
示例#5
0
 def decode(self, key, message):
     """metode for å dekode en melding"""
     decoded = []
     for number in message:
         decoded_number = pow(number, key[1], key[0])
         decoded.append(decoded_number)
     return crypto_utils.text_from_blocks(decoded, 2)
示例#6
0
    def decode(self, blocks, secret_key):
        """ Decode the encoded message with the decryption key """
        decoded_numbers = []

        sum_primes = secret_key[0]
        inverse_rand_num = secret_key[1]

        for number in blocks:
            decoded_number = pow(number, inverse_rand_num, sum_primes)
            decoded_numbers.append(decoded_number)

        decoded_message = text_from_blocks(decoded_numbers, 8)

        return decoded_message
示例#7
0
    def decode(self, encoded_text, key):
        """
        Decode message using private key
        :param encoded_text: encoded list of integers "c"s
        :param key: private key (n,d) used to decrypt
        :return: decrypted message
        """
        n, d = key
        decrypted_integers = []
        for c_encrypted in encoded_text:
            t_prime = pow(c_encrypted, d, n)
            decrypted_integers.append(t_prime)

        binary_message = text_from_blocks(decrypted_integers, self.__bits__)
        decrypted_message = [
            binary_message[i:i + 8] for i in range(0, len(binary_message), 8)
        ]
        decrypted_message = "".join(
            [chr(int(x, 2)) for x in decrypted_message])

        return decrypted_message
示例#8
0
 def decode(self, message, key):
     return crypto_utils.text_from_blocks(self.encode_decode(message, key),
                                          8)
示例#9
0
 def decode(key, encoded_text):
     return crypto_utils.text_from_blocks([pow(c, key[1], key[0]) for c in encoded_text], 8)
示例#10
0
 def decode(self, text, key):
     decrypted_numbers = []
     for number in text:
         decrypted_number = pow(number, key[1], key[0])
         decrypted_numbers.append(decrypted_number)
     return crypto_utils.text_from_blocks(decrypted_numbers, 2)
示例#11
0
 def decode(self, code, key):
     """Dekrypterer RSA-koden"""
     block_list_decoded = []
     for block in code:
         block_list_decoded.append(pow(block, key[1], key[0]))
     return crypto_utils.text_from_blocks(block_list_decoded, self.rsa_l)
示例#12
0
 def decode(self, text, key):
     decoded_blocks = []
     for val in self.c_list:
         decoded_blocks.append(
             pow(val, self.decryption_key[1], self.decryption_key[0]))
     return crypto_utils.text_from_blocks(decoded_blocks, 2)
 def decode(self, message, private_key):
     from crypto_utils import text_from_blocks
     n, d = private_key
     return text_from_blocks([pow(block, d, n) for block in message], 8)
示例#14
0
 def decode(self, text, key):
     n = key[0]
     d = key[1]
     dec_blocks = [pow(c, d, n) for c in text]
     return cu.text_from_blocks(dec_blocks, 1)
示例#15
0
文件: Crypto.py 项目: henrfj/TDT4113
 def decode(self, text, key):
     """key here is the receivers own private key, a tuple (n,d).
     'text' is in this case a list of encrypted integers"""
     for i in range(len(text)):
         text[i] = pow(text[i], key[1], key[0])
     return cu.text_from_blocks(text, 8)
示例#16
0
 def decode(self, cipher_text_blocks, key):
     new_blocks = []
     for block in cipher_text_blocks:
         new_blocks.append(decode_integer(block, key))
     return crypto_utils.text_from_blocks(new_blocks, 2)
示例#17
0
    def decode(block_text, private_key):

        for key, val in enumerate(block_text):
            block_text[key] = pow(val, private_key[1], private_key[0])

        return text_from_blocks(block_text, 1024)
示例#18
0
 def decode(self, cypher_text, receivers_key):
     for t_element in cypher_text:
         t_element = (t_element * receivers_key[1]) % receivers_key[0]
     return text_from_blocks(cypher_text, 8)
示例#19
0
 def decode(self, text, key):
     n, d = key
     blocks = [pow(t, d, n) for t in text]
     decoded_text = text_from_blocks(blocks, 1)
     return decoded_text
示例#20
0
 def decode(self, encrypted):
     decypted_decimals = [pow(c, self.d_own, self.n_own) for c in encrypted]
     print(f'Decimals decrypted: {decypted_decimals}')
     return text_from_blocks(decypted_decimals, 8)
示例#21
0
 def decode(self, code, key):
     '''Decode'''
     decrypted_list = [pow(number, key[1], key[0]) for number in code]
     message = crypto_utils.text_from_blocks(decrypted_list, 8)
     return message