toPem method

  1. @override
String toPem()
override

Implementation

@override
String toPem() {
  final writer = SSHMessageWriter();
  final checkInt = Random().nextInt(0xFFFFFFFF);

  writer.writeUint32(checkInt);
  writer.writeUint32(checkInt);
  writer.writeUtf8(name);
  writeTo(writer);

  // pad with bytes 1, 2, 3, ...
  for (var i = 0; writer.length % 8 != 0; i++) {
    writer.writeUint8(i + 1);
  }

  return OpenSSHKeyPairs.unencrypted(
    publicKeys: [toPublicKey().encode()],
    privateKeyBlob: writer.takeBytes(),
  ).toPem();
}