https://github.com/keybase/python-salsa20
Bindings for the NaCL implementation of Salsa20 and XSalsa20 by D. J. Bernstein
https://github.com/keybase/python-salsa20
Last synced: 16 days ago
JSON representation
Bindings for the NaCL implementation of Salsa20 and XSalsa20 by D. J. Bernstein
- Host: GitHub
- URL: https://github.com/keybase/python-salsa20
- Owner: keybase
- License: bsd-3-clause
- Archived: true
- Created: 2013-11-01T05:14:53.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2020-01-17T16:24:41.000Z (over 5 years ago)
- Last Synced: 2025-03-27T05:37:23.626Z (about 1 month ago)
- Language: C
- Size: 137 KB
- Stars: 32
- Watchers: 15
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
python-salsa20
==============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