Skip to content

Instantly share code, notes, and snippets.

import base64
import zlib
compressed = base64.b64encode(zlib.compress(decompressed))
@4poc
4poc / 1_encrypt.py
Last active December 13, 2016 10:31
Is this secure? (encrypted and signed(?))
import jose
from json import dumps
from Crypto.PublicKey import RSA
key = RSA.generate(2048)
private_key = key.exportKey('PEM').decode('utf-8')
public_key = key.publickey().exportKey('PEM').decode('utf-8')
from jwcrypto import jwk, jwe
from jwcrypto.common import json_encode
@4poc
4poc / gist:5761b0cdfd6d903d31a73c36aff22b90
Created February 23, 2017 16:41
python 3.4 vs. 3.5 incompatibility
def fun(a=0, b=0):
print(a, b)
fun(**{'b': 2}, a=1) # <--- breaks in 3.4
fun(a=1, **{'b': 2}) # works in 3.5
from uuid import uuid4
from time import time
from datetime import datetime, timedelta
import lmdb
def get_random(size):
def get_bytes():
return bytearray(size)
return get_bytes