程序
- 和AES的区别在于库不同,密钥和初始向量的长度不同;
from Crypto.Cipher import DES
import os
import time
cryptor = DES.new(
b'01234567',
DES.MODE_CBC,
b'01234567')
filepath = 'C:\\Users\\VikingsWu\\Desktop\\test.txt'
fp = open(filepath, 'rb')
file_size = os.path.getsize(filepath)
msg = fp.read()
msg_size = len(msg)
begin_time = time.perf_counter()
ciphertext = cryptor.encrypt(msg)
end_time = time.perf_counter()
run_time = end_time - begin_time
print(run_time)
ciphertext_size = len(ciphertext)
print(ciphertext)
结果
- 从运算时长来看,加密相同长度数据时,DES的运算速度更慢;
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/a6d0b60beec4595cbb79dda3e7d7edd0.png)