コード例 #1
0
def fdecrypt(filen, password, tweak=0, mode='twofish'):
	# reading file in byte mode
	f=open(filen,'rb')
	smstr=f.read()
	f.close()

	if mode=='twofish':
		psswd=Twofish(password)
		decredstr=b''

		# decrypting blocks
		for x in range(int(len(smstr)/16)):
			decredstr+=psswd.decrypt(smstr[x*16:(x+1)*16])

	elif mode=='threefish':

		psswd=threefish(password,tweak)
		decredstr=b''

		# decrypting blocks
		for x in range(int(len(smstr)/128)):
			decredstr+=psswd.decrypt_block(smstr[x*128:(x+1)*128])

	return decode(decredstr,'utf-8').strip('%')