使用python中的simplecrypt解密文件后损坏的文件

时间:2016-11-12 17:11:17

标签: python encryption

我尝试使用simplecrypt simplecrypt 加密解密视频,并且完美地工作,但问题是在程序解密后视频Myvideo.mp4.encexample-decrypt.mp4 example-decrypt.mp4无法使用"已损坏的文件"

我的代码:

from simplecrypt import encrypt, decrypt


def encrypt_file(file_name, key):
    with open(file_name, 'rb') as fo:
        plaintext = fo.read()
    enc = encrypt(key, plaintext)
    with open(file_name + ".enc", 'wb') as fo:
        fo.write(enc)


def decrypt_file(file_name, dec_file, key):
    with open(file_name, 'rb') as fo:
        ciphertext = fo.read()
    dec = decrypt(key, ciphertext)
    with open(dec_file, 'wb') as fo:
        fo.write(dec)

encrypt_file('Myvideo.mp4', 'xfxw3wxq233')
decrypt_file('Myvideo.mp4.enc', 'example-decrypt.mp4', 'xfxw3wxq233')

我如何解决这个问题。

0 个答案:

没有答案