encodeOpenSshPrivateKey

fun encodeOpenSshPrivateKey(keyPair: KeyPair, password: String? = null): String(source)

Encode a KeyPair to OpenSSH format (BEGIN OPENSSH PRIVATE KEY).

Return

OpenSSH-formatted private key string

Parameters

keyPair

JCA key pair to encode

password

Optional passphrase to encrypt the key (AES-256-CTR with bcrypt KDF)

Throws

if the key type is unsupported