isEncryptedPem static method

bool isEncryptedPem(
  1. String pemText
)

Implementation

static bool isEncryptedPem(String pemText) {
  final pem = SSHPem.decode(pemText);
  switch (pem.type) {
    case 'OPENSSH PRIVATE KEY':
      final pairs = OpenSSHKeyPairs.decode(pem.content);
      return pairs.isEncrypted;
    case 'RSA PRIVATE KEY':
      final pair = RsaKeyPair.decode(pem);
      return pair.isEncrypted;
    default:
      throw UnsupportedError('Unsupported key type: ${pem.type}');
  }
}