Dart
Dart
Convert DSA DER Private Key to PEM
See more DSA Examples
Converts a DSA private key from DER format to PEM. Demonstrates how to write both encrypted and unencrypted PEM formatted private keys.Chilkat Dart Downloads
import 'package:chilkat/chilkat.dart';
void main() {
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
final dsa = CkDsa();
// Load a DER private key.
try {
dsa.fromDerFile('dsa_priv.der');
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
var pemStr = '';
// Save to unencrypted PEM:
pemStr = dsa.toPem();
try {
dsa.saveText(pemStr, 'dsa_priv.pem');
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
// Save to encrypted PEM:
pemStr = dsa.toEncryptedPem('myPassword');
try {
dsa.saveText(pemStr, 'dsa_privEncrypted.pem');
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
print('Finished!');
}