//获取密钥对
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-09-12 17:12:18 发布
本文介绍如何在客户端使用JavaScript生成RSA加密的密钥对,包括公钥和私钥的创建过程,以及它们在安全通信中的应用。
摘要由CSDN通过智能技术生成