getPemFile function
Implementation
Future<PemFile> getPemFile(String path) async {
final pem = await File(path).readAsString();
if (pem.split(_beginPrivateKey).length > 1) {
return PemFile(
pem.split(_beginPrivateKey)[1],
KeyType.ed25519,
);
} else if (pem.split(_beginECPrivateKey).length > 1) {
return PemFile(
pem.split(_beginECPrivateKey)[1],
KeyType.secp265k1,
);
}
throw UnsupportedError('$path does not have a supported PEM type.');
}