Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function decryptPrivateKey(privateKey: openpgp.key): Promise {
let ok = false;
let firstTry = true;
do {
if (!firstTry) {
console.log('Wrong passphrase.');
}
const passphrase = await prompt('Private key passphrase: ', { method: 'hide' });
ok = privateKey.decrypt(passphrase);
firstTry = false;
} while (!ok);
}