This repository has been archived on 2026-03-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
TP-NSM/python/DES-20221006/test.py
2022-10-10 13:00:38 +02:00

25 lines
571 B
Python

from pyDes import *
from binascii import unhexlify as unhex
if __name__ == '__main__':
f = open("Image1.bmp", "rb")
head = f.read(62)
image = f.read()
f.close()
k1 = des(unhex("133457799BBCDFF1"), ECB, padmode=PAD_PKCS5)
k2 = des(unhex("133457799BBCDFF1"), CBC, IV=b'01110010', padmode=PAD_PKCS5)
e1 = k1.encrypt(image)
e2 = k2.encrypt(image)
with open("Image2.bmp", "wb") as f:
f.write(head)
f.write(e1)
with open("Image3.bmp", "wb") as f:
f.write(head)
f.write(e2)
# d1 = k1.decrypt(e1)