d.j.bernstein对salsa20和xsalsa20的nacl实现的绑定

salsa20的Python项目详细描述


D.J.Bernstein(摘自Libs钠)对SALSA20和XSALSA20 NaCl实施的绑定。

与Python2.6、2.7和3.3兼容。

库在每次导入时执行自检。

安装

pip install salsa20

用法

def Salsa20_keystream(length, nonce, key)
def Salsa20_xor(message, nonce, key)

def XSalsa20_keystream(length, nonce, key)
def XSalsa20_xor(message, nonce, key)

使用[X]Salsa20_keystream生成所需长度的密钥流,或通过[X]Salsa20_xor明文或密文将其与密钥流异或。

作为流密码,[X]Salsa20_xor同时进行加密和解密。

所有值都必须是二进制字符串(python 2上的str,python 3上的bytes

示例

>>> from salsa20 import XSalsa20_xor
>>> from os import urandom
>>> IV = urandom(24)
>>> KEY = b'*secret**secret**secret**secret*'
>>> ciphertext = XSalsa20_xor(b"IT'S A YELLOW SUBMARINE", IV, KEY)
>>> print(XSalsa20_xor(ciphertext, IV, KEY).decode())
IT'S A YELLOW SUBMARINE

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java为什么@DELETE REST不起作用?   带有JPA2的java表值参数。1和Hibernate,Sql Server   如何将Java类添加到Xamarin VS2017项目   绘制多边形时出现java空指针异常   java Apache WebClient 303状态未重定向   java如何用一组字符串数组从数据库中获取数据   java是否可以使用Google Drive API向文件中添加脚本?   java组织。阿帕奇。贾斯珀。JspC jar文件下载   java在整个JSON映射中将单个值作为JSON流   通过命令行将文件输入到java   java rs.next()总是返回false   java标记异常,通知调用方利用异常消息   java Spring YML数组属性为空