开发者

Generate rsa keypair client-side (on the browser)

I need to know how to g开发者_运维技巧enerate a rsa keypair on the cliente-side.

My system has to send encrypted data through the server and I have to ensure that the server cannot decrypt the data. So the Private/Public keypair cannot be generated on the server-side.

Any knowledge regarding this?

Thank you!


You should use the Web Cryptography API.

There's a specific example on MDN on how to generate an RSA key pair:

let keyPair = window.crypto.subtle.generateKey(
  {
    name: "RSA-OAEP",
    modulusLength: 4096,
    publicExponent: new Uint8Array([1, 0, 1]),
    hash: "SHA-256"
  },
  true,
  ["encrypt", "decrypt"]
);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜