コード例 #1
0
def decrypt(filename, directory, public_key, private_key):

    key = DH.generateSecret(long(private_key), long(public_key))
    str = key.encode('hex')
    key = str[0:32]
    file_obj = open(filename, "r")
    msg = file_obj.read()
    text = ENCDEC.AESCipher(key).decrypt(msg)
    outputFilename = os.path.join(directory, "DecodedFile.txt")
    file_obj = open(outputFilename, "w")
    file_obj.write(text)
    os.remove(filename)
    os.system("xdg-open " + directory)
コード例 #2
0
def encrypt(filename, directory, public_key, private_key):

    key = DH.generateSecret(long(private_key), long(public_key))
    str = key.encode('hex')
    key = str[0:32]
    file_obj = open(filename, "r")
    t = time.time()
    msg1 = ENCDEC.AESCipher(key).encrypt(file_obj.read())
    s = time.time()
    outputFilename = os.path.join(directory, key[16:] + ".txt")
    file_obj = open(outputFilename, 'w')
    file_obj.write(msg1)
    os.remove(filename)
    os.system("xdg-open " + directory)