Skip to content

Instantly share code, notes, and snippets.

@jcsaaddupuy
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcsaaddupuy/4d925ba1cdeb8aa57783 to your computer and use it in GitHub Desktop.
Save jcsaaddupuy/4d925ba1cdeb8aa57783 to your computer and use it in GitHub Desktop.
########### setup
## you should use a virtualenv...
## use the branch CCM of pycrypto
# git clone -b ccm git://github.com/Legrandin/pycrypto.git .
# cd pycrypto
# python setup.py build
# python setup.py install
#
# pip install sjcl
#########################
##################" the code, no bothering about expiration
from collections import OrderedDict
from sjcl import SJCL
import requests
import json
import base64
host="http://0bin.net"
key="DAKEY"
text="0xB16B00B5"
cyphertext = SJCL().encrypt(base64.b64encode(text), key)
# ordered dict because 0bin expect iv to be the first item... in a dict parsed as a string :/
data=OrderedDict()
data["iv"]=cyphertext["iv"]
data["salt"]=cyphertext["salt"]
data["ct"]=cyphertext["ct"]
r=requests.post("%s/%s" % (host, "paste/create"), data={"content": json.dumps(data)})
print "%s/paste/%s#%s" % (host, r.json()["paste"], key)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment