Skip to content

Instantly share code, notes, and snippets.

@mojojoseph
Created August 13, 2014 04:17
Show Gist options
  • Save mojojoseph/9b43bd35a7ab3812d7bd to your computer and use it in GitHub Desktop.
Save mojojoseph/9b43bd35a7ab3812d7bd to your computer and use it in GitHub Desktop.
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)
sodium.crypto_aead_chacha20poly1305_encrypt(c,
clen,
message,
mlen,
ad,
adlen,
None,
nonce,
key)
return c.raw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment