Bindings for the NaCL implementation of Salsa20 and XSalsa20 by D. J. Bernstein (taken from libsodium).
Compatible with Python 2.6, 2.7 and 3.3.
The library performs a self-test at each import.
Installation
pip install salsa20
Usage
def Salsa20_keystream(length, nonce, key) def Salsa20_xor(message, nonce, key) def XSalsa20_keystream(length, nonce, key) def XSalsa20_xor(message, nonce, key)
Use [X]Salsa20_keystream to generate a keystream of the desired length, or pass [X]Salsa20_xor a plaintext or a ciphertext to have it XOR’d with the keystream.
Being a stream cipher, [X]Salsa20_xor does both encryption and decryption.
All values must be binary strings (str on Python 2, bytes on Python 3)
Example
>>> 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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
salsa20-0.3.0.tar.gz
(6.1 kB
view details)
File details
Details for the file salsa20-0.3.0.tar.gz.
File metadata
- Download URL: salsa20-0.3.0.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a722e8b73088ead1d200f7d18f452d2c4df663a95b4462f69c4f130f17c60ed8
|
|
| MD5 |
5f199f3d6c643f05904b9d4a0b5d7e00
|
|
| BLAKE2b-256 |
79b1c3fd97c6ea566cdd47b8c216556a354cf68dae7bf170c9d64f2cd5ef2286
|