Python implementation of the Shannon stream cipher
Project description
py-shannon
Pure Python implementation of Shannon stream cipher. No-brainer port of shannon.
Shannon cipher is used in Spotify Connect to encrypt communication between player and Spotify AP server. Shannon cipher is variant of Sober stream cipher.
Example
Encryption
from shannon import Shannon
key = b"\x65\x87\xd8\x8f\x6c\x32\x9d\x8a\xe4\x6b"
message = "My secret message".encode("utf-8")
shannon = Shannon(key)
message = shannon.encrypt(message) # -> bytes
# message contains ciphertext now
mac = shannon.finish() # -> bytes
# mac contains MAC of the message
Decryption
from shannon import Shannon
key = b"\x65\x87\xd8\x8f\x6c\x32\x9d\x8a\xe4\x6b"
# message is encrypted
message = b"\x91\x9d\xa9\xb6\x29\xfc\x9c\xdd\x17\x8c\x15\x31\x9a\xae\xcc\x6e\xd4"
received_mac = b"\xbe\x7b\xef\x39\xee\xfe\x54\xfd\x8d\xb0\xbc\x6f\xd5\x30\x35\x19"
shannon = Shannon(key)
message = shannon.decrypt(message) # -> bytes
# message contains plaintext now
mac = shannon.finish()
if mac == received_mac:
print("MAC OK")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
py-shannon-1.0.1.tar.gz
(4.1 kB
view hashes)
Built Distribution
Close
Hashes for py_shannon-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18804d13ade7b510bf41c02880c785933ea733fd74d8e4c69f6d6a7bf536af92 |
|
MD5 | bcc9bbf6c6505d24255aa82c41a98101 |
|
BLAKE2b-256 | 53854c6db48bca49de779811e0b2d7e4ece0f8aa2a5e494e744188b6fec571cb |