Skip to main content

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

Metadata

Release files for salsa20 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for salsa20 0.3.0
File Size Uploaded Provenance Actions
salsa20-0.3.0.tar.gz 6.1 kB Without provenance Details for salsa20-0.3.0.tar.gz

Release files / salsa20-0.3.0.tar.gz

Download URL salsa20-0.3.0.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
a722e8b73088ead1d200f7d18f452d2c4df663a95b4462f69c4f130f17c60ed8
BLAKE2b-256 checksum
How to use checksums
79b1c3fd97c6ea566cdd47b8c216556a354cf68dae7bf170c9d64f2cd5ef2286
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for salsa20 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page