Пример #1
0
 def decode_message(self, data_id_json, own_keys_path):
     try:
         data_id = json.loads(data_id_json)
         exp_time = int(data_id['exp_time'])
     except Exception as e:
         print("[ERROR] exception: ", (e.message))
         print("[ERROR] wrong data_id format from")
         raise DecodeError
     if (int(time.time()) > exp_time):
         print("[ERROR] expired message from")
         raise DecodeError
     b64_data = bytes(base64.b64decode(data_id['data']))
     data = my_rsa.unpack(b64_data)
     return my_rsa.decode(data, own_keys_path)
Пример #2
0
def decode_message(data_id_json, client):
    try:
        data_id = json.loads(data_id_json)
        exp_time = int(data_id['exp_time'])
    except Exception as e:
        print("[ERROR] exception: ", (e.message))
        print("[ERROR] wrong data_id format from" + repr(client[1]))
        raise DecodeError
    if (int(time.time()) > exp_time):
        print("[ERROR] expired message from" + repr(client[1]))
        raise DecodeError
    b64_data = bytes(base64.b64decode(data_id['data']))
    data = my_rsa.unpack(b64_data)
    return my_rsa.decode(data, "../numbers.txt")
Пример #3
0
#!/usr/bin/python3
import sys
import my_rsa

chiper_text = my_rsa.encode(sys.argv[1], "numbers.txt")
clear_text = my_rsa.decode(chiper_text, "numbers.txt")