From 01469ec5a0c08644fa8d539ad62a4d94e6842de6 Mon Sep 17 00:00:00 2001 From: YeMingfei666 <1619116647@qq.com> Date: Tue, 10 Sep 2024 15:26:29 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=BD=95=E8=B4=A6=E5=8F=B7=E5=8A=A0?= =?UTF-8?q?=E5=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commons/utils/rsaEncrypt.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 commons/utils/rsaEncrypt.js diff --git a/commons/utils/rsaEncrypt.js b/commons/utils/rsaEncrypt.js new file mode 100644 index 0000000..1948ddd --- /dev/null +++ b/commons/utils/rsaEncrypt.js @@ -0,0 +1,14 @@ +import JSEncrypt from 'jsencrypt/bin/jsencrypt.min' + +// 密钥对生成 http://web.chacuo.net/netrsakeypair + +const publicKey = 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANL378k3RiZHWx5AfJqdH9xRNBmD9wGD\n' + + '2iRe41HdTNF8RUhNnHit5NpMNtGL0NPTSSpPjjI1kJfVorRvaQerUgkCAwEAAQ==' + +// 加密 +export function encrypt(txt) { + const encryptor = new JSEncrypt() + encryptor.setPublicKey(publicKey) // 设置公钥 + return encryptor.encrypt(txt) // 对需要加密的数据进行加密 +} +