Python密码学

一次密码实现

一次密码键盘的实现详细操作教程
Python包括一个用于 一次性密码密码实现的hacky实现模块。程序包名称称为"一次性垫",其中包括一个命令行加密工具,该工具使用类似于一次性填充密码算法的加密机制。

安装

您可以使用以下命令来安装此模块-
# Filename : example.py
# Copyright : 2020 By Lidihuo
# Author by : www.lidihuo.com
# Date : 2020-08-28
pip install onetimepad
如果您希望从命令行使用它,请运行以下命令-
# Filename : example.py
# Copyright : 2020 By Lidihuo
# Author by : www.lidihuo.com
# Date : 2020-08-28
onetimepad
 PIP

代码

以下代码有助于生成一次性填充密码-
# Filename : example.py
# Copyright : 2020 By Lidihuo
# Author by : www.lidihuo.com
# Date : 2020-08-28
import onetimepad
cipher = onetimepad.encrypt('One Time Cipher', 'random')
print("Cipher text is ")
print(cipher)
print("Plain text is ")
msg = onetimepad.decrypt(cipher, 'random')
print(msg)

输出

运行上面给出的代码时,您可以观察到以下输出-
 PIP输出
注意-如果密钥的长度小于消息的长度(纯文本),则加密的消息非常容易破解。
无论如何,密钥不一定是随机的,这使一次性填充密码成为一种有价值的工具。
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4