def _getPersistentRSAKey(location, keySize=4096):
 location.parent().makedirs(ignoreExistingDirectory=True)
 if (not location.exists()):
  privateKey = rsa.generate_private_key(public_exponent=65537, key_size=keySize, backend=default_backend())
  pem = privateKey.private_bytes(encoding=serialization.Encoding.PEM, format=serialization.PrivateFormat.TraditionalOpenSSL, encryption_algorithm=serialization.NoEncryption())
  location.setContent(pem)
 with location.open('rb') as keyFile:
  privateKey = serialization.load_pem_private_key(keyFile.read(), password=None, backend=default_backend())
  return Key(privateKey)

def _getPersistentRSAKey ( location , keySize = 4096 ) : location . parent ( ) . makedirs ( ignoreExistingDirectory = True ) if ( not location . exists ( ) ) : privateKey = rsa . generate_private_key ( public_exponent = 65537 , key_size = keySize , backend = default_backend ( ) ) pem = privateKey . private_bytes ( encoding = serialization . Encoding . PEM , format = serialization . PrivateFormat . TraditionalOpenSSL , encryption_algorithm = serialization . NoEncryption ( ) ) location . setContent ( pem ) with location . open ( 'rb' ) as keyFile : privateKey = serialization . load_pem_private_key ( keyFile . read ( ) , password = None , backend = default_backend ( ) ) return Key ( privateKey )
this function returns a persistent l{key} .