rsaPrivateKeyFromPEM function

RSAPrivateKey rsaPrivateKeyFromPEM(
  1. String pemString
)

Create an RSAPrivateKey from the given PEM-String.

Implementation

RSAPrivateKey rsaPrivateKeyFromPEM(String pemString) {
  final rows = pemString.split(RegExp(r'\r\n?|\n'));
  final privateKeyString = rows
      .skipWhile((row) => row.startsWith('-----BEGIN'))
      .takeWhile((row) => !row.startsWith('-----END'))
      .map((row) => row.trim())
      .join('');
  return rsaPrivateKeyFromString(privateKeyString);
}