Skip to content

Instantly share code, notes, and snippets.

def crypto_aead_chacha20poly1305_encrypt(message,
ad,
nonce,
key):
mlen = ctypes.c_ulonglong(len(message))
adlen = ctypes.c_ulonglong(len(ad))
c = ctypes.create_string_buffer(mlen.value+16L)
clen = ctypes.c_ulonglong(0)
@mojojoseph
mojojoseph / gist:c555110400060bcf99a3
Created August 13, 2014 04:15
PySodium With Binding for ChaCha20Poly1305
from pysodium import crypto_aead_chacha20poly1305_encrypt
from bitstring import BitStream
key = BitStream(hex="4290bcb154173531f314af57f3be3b5006da371ece272afa1b5dbdd1100a1007")
nonce = BitStream(hex="cd7cf67be39c794a")
ad = BitStream(hex="87e229d4500845a079c0")
msg = BitStream(hex="86d09974840bded2a5ca")
print(key)
print(nonce)