Open yaofly2012 opened 2 years ago
全称:Advanced Encyption Standard,即:高级加密标准 作为DES的替代品。
根据算法密钥的长度(bit),AES有3种不同方案用以满足不同的场景需求,分别是:
秘钥长度递增64bit(8个字节)。
Pretty Good Privacy (PGP) is an encryption system used for both sending encrypted emails and encrypting sensitive files.
passphrase
在加密/解密过程中作用passphrase
用来对秘钥进行再次加密,这样在使用私钥时需要先解密私钥。
const openpgp = require('openpgp'); // use as CommonJS, AMD, ES6 module or via window.openpgp
(async () => {
// put keys in backtick (``) to avoid errors caused by spaces or tabs
const publicKeyArmored = ``;
const privateKeyArmored = ``; // encrypted private key
const passphrase = 'abcd'; // what the private key is encrypted with
const publicKey = await openpgp.readKey({ armoredKey: publicKeyArmored });
// 没有passphrase方式
// const privateKey = await openpgp.readPrivateKey({ armoredKey: privateKeyArmored })
// 存在passphrase密码
const privateKey = await openpgp.decryptKey({
privateKey: await openpgp.readPrivateKey({ armoredKey: privateKeyArmored }),
passphrase
});
})();
加密入门
最近刚好要使用
crypto
模块,发现好些概念不懂,就整理了下。 本文并不能算是算法入门介绍,就是混个脸熟,了解一些相关概念。至于算法本身不属于本文内容(个人能力之外哈)。基本概念
分类
对称加密
加解密使用相同的密钥。
非对称加密
两者关系:
用公钥加密的数据必须用私钥才能解开,同样私钥加密的数据只有公钥能解开。但是私钥加密的数据是不安全的,因为公钥是大家都知道的,都可以解密用私钥加密的数据。
那私钥加密数据有什么用呢?
私钥用于签名、公钥用于验签 私钥具有私有性适合用在签名用途上,防止数据被篡改。
公钥用于加密、私钥用于解密,这才能起到加密作用
参考