def dump_crypto_meta(crypto_meta):
 def b64_encode_meta(crypto_meta):
  return {name: (base64.b64encode(value).decode() if (name in ('iv', 'key')) else (b64_encode_meta(value) if isinstance(value, dict) else value)) for (name, value) in crypto_meta.items()}
 return urlparse.quote_plus(json.dumps(b64_encode_meta(crypto_meta), sort_keys=True))

def dump_crypto_meta ( crypto_meta ) : def b64_encode_meta ( crypto_meta ) : return { name : ( base64 . b64encode ( value ) . decode ( ) if ( name in ( 'iv' , 'key' ) ) else ( b64_encode_meta ( value ) if isinstance ( value , dict ) else value ) ) for ( name , value ) in crypto_meta . items ( ) } return urlparse . quote_plus ( json . dumps ( b64_encode_meta ( crypto_meta ) , sort_keys = True ) )
serialize crypto meta to a form suitable for including in a header value .