目录

一次性密码密码的实现(Implementation of One Time Pad Cipher)

Python包含一个用于one-time-pad密码密码实现的hacky实现模块。 包名称称为One-Time-Pad,其中包括一个命令行加密工具,该工具使用类似于一次性密码密码算法的加密机制。

安装 (Installation)

您可以使用以下命令安装此模块 -

pip install onetimepad

如果要从命令行使用它,请运行以下命令 -

onetimepad

PIP

Code

以下代码有助于生成一次性密码密码 -

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)

输出 (Output)

运行上面给出的代码时,您可以观察到以下输出 -

PIP输出

Note - 如果密钥长度小于消息长度(纯文本),则加密消息很容易破解。

在任何情况下,密钥不一定是随机的,这使得一次性密码密码成为一种有价值的工具。

↑回到顶部↑
WIKI教程 @2018