Пример #1
0
 def test_sample_text(self):
     text = "Lorem Ipsum is simply dummy text of the printing and typesetting industry."
     pub_key, priv_key = rsa.gen_key()
     encrypt_data = rsa.encrypt_rsa(text, pub_key)
     self.assertEqual(text, rsa.decode_rsa(encrypt_data, priv_key))
Пример #2
0
async def decode_data(decodeData: DecodeData):
    """ Decode data request """
    result = rsa.decode_rsa(decodeData.text, decodeData.key)
    return {"result": result}
Пример #3
0
 def test_decode_rsa_encrypt_massage_1(self):
     self.assertEqual(decode_rsa([899, 611], 308), (60))
Пример #4
0
 def test_decode_encode(self):
     pubk, prk = rsa(13)
     r = random.randint(1, 500)
     for i in range(1, r):
         self.assertEqual(decode_rsa(prk, encode_rsa(pubk, i)), i)
Пример #5
0
import rsa

d, n = input("Enter private key: ").split()
d = int(d)
n = int(n)

with open('message.txt', 'r') as file:
    code = file.readline().split(sep=' ')
    code = code[:-1]
    code = [int(c) for c in code]

message = [rsa.decode_rsa(c, d, n) for c in code]
message = [chr(c) for c in message]

message = ''.join(message)

print(message)