Last active
August 29, 2015 14:05
-
-
Save jcsaaddupuy/4d925ba1cdeb8aa57783 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########### 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