0
gzip으로 압축 된 데이터 파일과 DES 암호화가 전송되었습니다. 암호화를 해제하고 압축을 풀고 싶습니다. 파일의 암호를 해독 할 수압축 된 파일 및 DES 암호화 된 파일 읽기
내 코드는이
from Crypto.Cipher import DES
key = 'XXXXXXXX'
mode = DES.MODE_ECB
des = DES.new(key, mode)
input_file = r'C:\Users\UserName\Documents\Somefile.gz.des.20141001'
with open(input_file, 'rb') as file:
ciphertext = file.read().replace('\n', ' ')
text = des.decrypt(ciphertext)
output_file = r'C:\Users\UserName\Documents\Somefile.gz.20141001'
with open(file_name, 'wb') as file:
file.write(text)
과 같은 문제 출력 파일이 난 이후에 파일을 압축 해제 할 수 있다는 점에서, 제대로 해독 할 수 표시되지 않는다는 것입니다; 그것은 gzipped 파일로 인식되지 않습니다.
오른쪽 키를 사용하고 있다는 것을 두 번 확인하고 트리플을 확인했습니다. 그 밖의 무엇이 잘못 될 수 있습니까? 이 문제
with open(input_file, 'rb') as file:
ciphertext = file.read().replace('\n', ' ')
#I doubt that the original encryptor replaced spaces with newlines after they encrypted it
text = des.decrypt(ciphertext)
것을 당신이
을 시도 할 수 있습니다 내가 자상 할게요 말했다 당신이 당신의 문제 나 해결책이 무슨 말을하는 것은 불가능 제공 한 정보 ...와
왜 당신이해야합니까? 'ciphertext = file.read(). replace ('\ n', '')'? 그럴 수도 있고 그렇지 않을 수도 있습니다 ... 암호화 된 후 공백이 새로운 줄로 바뀌는 지 의심 스럽습니다 –
CBC가 아닌 ECB입니까? –