def setUp(self): file_fp, file_path = mkstemp() self.password = '******' self.crypto = Crypto(self.password) self.file_path = file_path self.file_entry = FileEntry.from_file(file_path, os.path.basename(file_path)) os.close(file_fp)
def sync_folders(folder): if not DataEncryptionHandler.encryption_enabled(): return encrypted_folder = DataEncryptionHandler.compute_encrypted_folder_path( folder) crypto_pass = os.environ[ DataEncryptionHandler. CRYPTO_PASS] if DataEncryptionHandler.CRYPTO_PASS in os.environ else None if crypto_pass is None: raise TVBException( "Storage encryption/decryption is not possible because password is not provided." ) crypto = Crypto(crypto_pass) syncro = Syncrypto(crypto, encrypted_folder, folder) syncro.sync_folder() trash_path = os.path.join(encrypted_folder, "_syncrypto", "trash") if os.path.exists(trash_path): shutil.rmtree(trash_path)
def sync_folders(folder): if not DataEncryptionHandler.encryption_enabled(): return project_name = os.path.basename(folder) encrypted_folder = DataEncryptionHandler.compute_encrypted_folder_path( folder) if os.path.exists(encrypted_folder) or os.path.exists(folder): crypto_pass = DataEncryptionHandler._project_key(project_name) crypto = Crypto(crypto_pass) syncro = Syncrypto(crypto, encrypted_folder, folder) syncro.sync_folder() trash_path = os.path.join(encrypted_folder, "_syncrypto", "trash") if os.path.exists(trash_path): shutil.rmtree(trash_path) else: LOGGER.info("Project {} was deleted".format(project_name))
def setUp(self): self.crypto = Crypto('password') self.plain_folder = mkdtemp() self.plain_folder_check = mkdtemp() self.encrypted_folder = mkdtemp() prepare_filetree( self.plain_folder, ''' sync_file_modify:hello world sync_file_delete:delete sync/file/modify:hello world empty_dir_delete/ not_empty_dir/dir2/dir3/file dir2/file2 ''') self.plain_tree = self.plain_tree = FileTree.from_fs(self.plain_folder) self.plain_tree_check = FileTree() self.encrypted_tree = FileTree() self.snapshot_tree = FileTree()
from time import time from syncrypto import Crypto, Syncrypto bufferSize = 64 * 1024 password = "******" folder = "/Users/bvalean/TVB/PROJECTS/Default_Project" folder_encrypted = "/Users/bvalean/WORK/test-encryption/Default_Project_encrypted" folder_decrypted = "/Users/bvalean/WORK/test-encryption/Default_Project_decrypted" if __name__ == '__main__': print("========== ENCRYPTION ==========") crypto = Crypto(password) syncro1 = Syncrypto(crypto,folder_encrypted,folder) t = time() syncro1.sync_folder() print("========== FINISH ENCRYPTION ==========") encryption = time()-t print("========== DECRYPTION ==========") syncro1 = Syncrypto(crypto,folder_encrypted,folder_decrypted) t = time() syncro1.sync_folder() print("========== FINISH DECRYPTION ==========") decryption = time() - t print("========== RESULTS ==========") print("Ecrypted: {} seconds".format(encryption)) print("Decrypted: {} seconds".format(decryption))