admin管理员组文章数量:1406032
I'm facing an issue when trying to use PGP keys generated by openpgpjs
with pgpy
in Python. Specifically, I am encountering the following error:
14 is not a valid HashAlgorithm
Here is my openpgpjs key generation :
const fs = require('fs');
const openpgp = require('openpgp');
// Function to generate PGP keys and save them to files
async function generateAndWritePGPKeys() {
// Generate PGP keys
const { privateKey, publicKey } = await openpgp.generateKey({
type: 'rsa',
rsaBits: 4096,
userIDs: [{ name: 'John Doe', email: '[email protected]' }],
passphrase: 'SuperSecurePassphrase123!',
format: 'armored'
});
// Define paths for the files
const privateKeyPath = './priv1.pgp';
const publicKeyPath = './pub1.pgp';
// Write the keys to files
fs.writeFileSync(privateKeyPath, privateKey.replace(/\r/g, ''));
fs.writeFileSync(publicKeyPath, publicKey.replace(/\r/g, ''));
console.log('PGP Keys have been written to files:');
console.log(`Private Key: ${privateKeyPath}`);
console.log(`Public Key: ${publicKeyPath}`);
}
// Run the function to generate and write keys
generateAndWritePGPKeys();
Here is my python code :
def loadkey(key_path):
try:
key, _ = PGPKey.from_file(key_path)
except Exception as e:
print(str(e))
return None
return key
本文标签:
版权声明:本文标题:python - Incompatible PGP keys between openpgp.js and pgpy: Error "14 is not a valid HashAlgorithm" - Stack Ov 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744966070a2634954.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论