generateKeyPairAsPem static method
Returns a pair of keys in PEM format
bitLength - The length of the key in bits (default: 2048)
Returns a CryptoKeyPair object containing public and private keys
Implementation
static LicensifyKeyPair generateKeyPairAsPem({int bitLength = 2048}) {
final keyPair = generateKeyPair(bitLength: bitLength);
// Convert keys to PEM format
final publicKeyPem = CryptoUtils.encodeRSAPublicKeyToPem(keyPair.publicKey);
final privateKeyPem = CryptoUtils.encodeRSAPrivateKeyToPem(
keyPair.privateKey,
);
// Create key objects with proper type
final privateKey = LicensifyPrivateKey.rsa(privateKeyPem);
final publicKey = LicensifyPublicKey.rsa(publicKeyPem);
return LicensifyKeyPair(privateKey: privateKey, publicKey: publicKey);
}