【问题标题】:JS frontend encryption with public-private keyJS前端加密公私钥
【发布时间】:2020-06-18 03:09:46
【问题描述】:

我正在尝试使用 javascript 加密前端中的一些字符串,使用一些公钥-私钥方法,其中只有后端可以使用私钥解密,这可能吗?我怎样才能实现它?

我不介意它是否具有真正的基本加密,只要它有一个公共和私人密钥

// This is an EXAMPLE of what I want:

let message = encrypt("hello word!","public_key");
let decrypt_message = decrypt(message, "public_key");

/* the decrypt() method should throws error cuz the user shouldn't be able to
 * decrypt his own message with the public_key
 */

还请注意,我已经在使用 HTTPS,但具有额外的安全性并不会伤害任何人 :)

提前谢谢你♥

【问题讨论】:

    标签: javascript encryption


    【解决方案1】:

    CryptoJS / crypto-js 和 JSEncrypt / jsencrypt 是您可以使用的库。

    您需要加密您的数据加密密钥以发送到后端,然后您可以在后端使用私钥和加密密钥对其进行解码。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-02-29
      • 2018-02-27
      • 2013-04-06
      • 2012-04-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多