Esempio n. 1
0
 def test_encrypt_file_smp_single_file(self):
     """
     test_encrypt_file
     """
     self.do_wait_for_tasks = False
     fname = "testdata/200MB.zip"
     secret = '\xeb>M\x04\xc22\x96!\xce\xed\xbb.\xe1u\xc7\xe4\x07h<.\x87\xc9H\x89\x8aj\xb4\xb2b5}\x95'
     enc_file = encrypt_file_smp(secret, fname, print_progress, single_file=True)
     dec_file = decrypt_file_smp(secret, enc_file=enc_file, progress_callback=print_progress)
     self.assertEqual(make_sha1_hash_file(fpi=dec_file), make_sha1_hash_file(fpi=open(fname)))
Esempio n. 2
0
    def test_encrypt_file_smp(self):
        """
        test_encrypt_file
        """
        self.do_wait_for_tasks = False

        #self.make_testfile("1000MB.zip", 1000)
        fname = "testdata/200MB.zip"
        secret = '\xeb>M\x04\xc22\x96!\xce\xed\xbb.\xe1u\xc7\xe4\x07h<.\x87\xc9H\x89\x8aj\xb4\xb2b5}\x95'
        enc_files = encrypt_file_smp(secret, fname, print_progress)
        dec_file = decrypt_file_smp(secret, enc_files=enc_files, progress_callback=print_progress, delete_enc_files=True)
        h1 = make_sha1_hash_file(fpi=dec_file)
        h2 = make_sha1_hash_file(fpi=open(fname))
        self.assertEqual(h1, h2)
Esempio n. 3
0
def read_and_encrypt_file(fpath, blobpath, secret):
    """
    @type fpath: str or unicode
    @type blobpath: str or unicode
    @type secret: str or unicode
    @return: @rtype:
    """
    enc_file_paths = encrypt_file_smp(secret, fpath, progress_callback=update_item_progress)
    enc_file_paths = [x for x in enumerate(enc_file_paths)]
    with open(blobpath, "w") as configfp:
        for chunk_path in enc_file_paths:
            path = blobpath + "_" + str(chunk_path[0])
            os.rename(chunk_path[1], path)
            configfp.write(path + "\n")

    return True
Esempio n. 4
0
def read_and_encrypt_file(fpath, blobpath, secret):
    """
    @type fpath: str or unicode
    @type blobpath: str or unicode
    @type secret: str or unicode
    @return: @rtype:
    """
    enc_file_paths = encrypt_file_smp(secret,
                                      fpath,
                                      progress_callback=update_item_progress)
    enc_file_paths = [x for x in enumerate(enc_file_paths)]
    with open(blobpath, "w") as configfp:
        for chunk_path in enc_file_paths:
            path = blobpath + "_" + str(chunk_path[0])
            os.rename(chunk_path[1], path)
            configfp.write(path + "\n")

    return True