//获取密钥对
function getRsaKeys(func){
window.crypto.subtle.generateKey(
{
name: "RSA-OAEP",
modulusLength: 2048, //can be 1024, 2048, or 4096
publicExponent: new Uint8Array([0x01, 0x00, 0x01]),
hash: {name: "SHA-512"}, //can be "SHA-1", "SHA-256", "SHA-384", or "SHA-512"
},
true, //whether the key is extractable (i.e. can be used in exportKey)
["encrypt", "decrypt"] //must be ["encrypt", "decrypt"] or ["wrapKey", "unwrapKey"]
).then(function(key){
window.crypto.subtle.exportKey(
"pkcs8",
key.privateKey
).then(function(keydata1){
window.crypto.subtle.exportKey(
"spki",
key.publicKey
).then(function(keydata2){
var privateKey = RSA2text(keydata1,1);
va
客户端js生成rsa 密钥对
最新推荐文章于 2024-05-26 17:32:11 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)