React Native
React Native
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 React Native Downloads
import { Dsa } from '@chilkat/react-native'
function chilkatExample() {
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
const dsa = new Dsa();
// Load a DER private key.
try {
dsa.fromDerFile('dsa_priv.der');
} catch {
console.log(dsa.lastErrorText);
return;
}
let pemStr = '';
// Save to unencrypted PEM:
pemStr = dsa.toPem();
try {
dsa.saveText(pemStr, 'dsa_priv.pem');
} catch {
console.log(dsa.lastErrorText);
return;
}
// Save to encrypted PEM:
pemStr = dsa.toEncryptedPem('myPassword');
try {
dsa.saveText(pemStr, 'dsa_privEncrypted.pem');
} catch {
console.log(dsa.lastErrorText);
return;
}
console.log('Finished!');
}