コード例 #1
0
ファイル: encrypt_test.py プロジェクト: hwind/hwindCode
	def test_encrypt_decrypt(self):
		path = "testdata//test.mkv"
		with open(path, "rb") as in_f, open(path+".tmp", "wb") as out_f:
			encrypt.encrypt(in_f, out_f, "Password01!")

		with open(path+".tmp", "rb") as in_f, open(path+".tmp2", "wb") as out_f:
			encrypt.decrypt(in_f, out_f, "Password01!")

		with open(path+".tmp", "rb") as in_f, open(path+".tmp3", "wb") as out_f:
			encrypt.decrypt(in_f, out_f, "Password02!")

		p1 = fileprocessor.FileProcessor(path)
		p2 = fileprocessor.FileProcessor(path+".tmp2")
		p3 = fileprocessor.FileProcessor(path+".tmp3")
		
		self.assertEqual(p1.md5, p2.md5)
		self.assertNotEqual(p1.md5, p3.md5)
コード例 #2
0
ファイル: fileprocessor.py プロジェクト: hwind/hwindCode
    def chuncks(self):
        if self.__chuncks == None:
            cur_size = 0
            if config.is_encrypt():
                tmp_path = self.__file_path + ".tmp"
                with open(self.__file_path, "rb") as in_f, open(tmp_path, "wb") as out_f:
                    encrypt.encrypt(in_f, out_f, config.config["pwd"])
                cur_size = os.path.getsize(tmp_path)
            else:
                cur_size = self.size

            if cur_size % FileProcessor.__CHUNCK_SIZE == 0:
                self.__chuncks = cur_size // FileProcessor.__CHUNCK_SIZE
            else:
                self.__chuncks = cur_size // FileProcessor.__CHUNCK_SIZE + 1
        
        return self.__chuncks