Create a gist now

Instantly share code, notes, and snippets.

@4poc /
Last active Dec 13, 2016

What would you like to do?
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
payload = {
'url': '',
'user': 'asdfasdfasdf asdf saa sd fdas'
jwk_public_key = jwk.JWK.from_pem(bytes(public_key, 'utf-8'))
jwetoken = jwe.JWE(dumps(payload), json_encode({'alg': 'RSA-OAEP', 'enc': 'A128CBC-HS256'}))
encrypted = jwetoken.serialize(True) # True for compact
var jose = require('node-jose');
const keystore = jose.JWK.createKeyStore();
const private_key = ...;
keystore.add(private_key, 'pem').
then((result) => {
then((result) => {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment