How to use the jwcrypto.jwk.JWK.generate function in jwcrypto

To help you get started, we’ve selected a few jwcrypto examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github davedoesdev / python-jwt / test / fixtures.py View on Github external
'PS512': {'python-jwt': priv_key}
}

pub_keys = {
    'HS256': {'default': priv_keys['HS256']['default']},
    'HS384': {'default': priv_keys['HS384']['default']},
    'HS512': {'default': priv_keys['HS512']['default']},
    'RS256': {'python-jwt': pub_key},
    'RS384': {'python-jwt': pub_key},
    'RS512': {'python-jwt': pub_key},
    'PS256': {'python-jwt': pub_key},
    'PS384': {'python-jwt': pub_key},
    'PS512': {'python-jwt': pub_key}
}

generated_key = JWK.generate(kty='RSA', size=2048)

generated_keys = {
    'HS256': JWK(kty='oct', k=base64url_encode(hexlify(urandom(16)))),
    'HS384': JWK(kty='oct', k=base64url_encode(hexlify(urandom(16)))),
    'HS512': JWK(kty='oct', k=base64url_encode(hexlify(urandom(16)))),
    'RS256': generated_key,
    'RS384': generated_key,
    'RS512': generated_key,
    'PS256': generated_key,
    'PS384': generated_key,
    'PS512': generated_key
}

algs = list(priv_keys.keys())
github plone / guillotina / guillotina / commands / crypto.py View on Github external
async def run(self, arguments, settings, app):
        key = jwk.JWK.generate(kty=arguments.key_type, size=arguments.key_size)
        print(key.export())
github davedoesdev / python-jwt / bench / generate_key_bench.py View on Github external
def bench_RSA(self):
        """ Generate key """
        JWK.generate(kty='RSA', size=2048)
github plone / guillotina / guillotina / utils / crypto.py View on Github external
def get_jwk_key(settings=None):
    if settings is None:
        settings = app_settings
    if settings.get("jwk") is None:
        if not settings.get("debug"):
            logger.warning(
                "You are utilizing JWK keys but you have not provided "
                "a jwk key setting in your application settings. "
                "A key has been dynamically generated for you; however, "
                "if you are running more than one guillotina process, "
                "the key will NOT be shared between them and your "
                "application will not function properly"
            )
        key = jwk.JWK.generate(kty="oct", size=256)
        settings["jwk"] = key
    return settings["jwk"]