INNER CODE UNIT · Python
ssh_key_sign
nordnet/next-api-v2-examples · python3/sign.py:28
def ssh_key_sign(private_key_path, challenge):
"""
Calculate the signature of a challenge using an ed25519 private key
Args:
private_key_path: Path to your private key file (e.g., id_ed25519)
challenge: The challenge to sign
Returns:
The base64 encoded signature
"""
# Load the private key
try:
with open(private_key_path, "rb") as key_file:
private_key = serialization.load_ssh_private_key(
key_file.read(),
password=None, # If your key has a passphrase, provide it here
backend=default_backend()