From 9f97fd0953484f061d0987816dee1bb614519697 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Wed, 20 Nov 2019 11:53:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0jsencrypt=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E7=9A=84=E5=89=8D=E7=AB=AF=E5=8A=A0=E5=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/package.json | 3 ++- ruoyi-ui/src/utils/jsencrypt.js | 30 ++++++++++++++++++++++++++++++ ruoyi-ui/src/views/login.vue | 5 +++-- 3 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 ruoyi-ui/src/utils/jsencrypt.js diff --git a/ruoyi-ui/package.json b/ruoyi-ui/package.json index ae3a5c30..d6f08df0 100644 --- a/ruoyi-ui/package.json +++ b/ruoyi-ui/package.json @@ -40,7 +40,7 @@ "url": "https://gitee.com/y_project/RuoYi-Vue.git" }, "dependencies": { - "@riophae/vue-treeselect": "0.1.0", + "@riophae/vue-treeselect": "0.4.0", "vue-quill-editor": "3.0.6", "vue-cropper": "0.4.9", "axios": "0.18.1", @@ -48,6 +48,7 @@ "element-ui": "2.11.1", "fuse.js": "3.4.4", "js-cookie": "2.2.0", + "jsencrypt": "3.0.0-rc.1", "normalize.css": "7.0.0", "nprogress": "0.2.0", "path-to-regexp": "2.4.0", diff --git a/ruoyi-ui/src/utils/jsencrypt.js b/ruoyi-ui/src/utils/jsencrypt.js new file mode 100644 index 00000000..83db4809 --- /dev/null +++ b/ruoyi-ui/src/utils/jsencrypt.js @@ -0,0 +1,30 @@ +import JSEncrypt from 'jsencrypt/bin/jsencrypt' + +// 密钥对生成 http://web.chacuo.net/netrsakeypair + +const publicKey = 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANL378k3RiZHWx5AfJqdH9xRNBmD9wGD\n' + + '2iRe41HdTNF8RUhNnHit5NpMNtGL0NPTSSpPjjI1kJfVorRvaQerUgkCAwEAAQ==' + +const privateKey = 'MIIBUwIBADANBgkqhkiG9w0BAQEFAASCAT0wggE5AgEAAkEA0vfvyTdGJkdbHkB8\n' + + 'mp0f3FE0GYP3AYPaJF7jUd1M0XxFSE2ceK3k2kw20YvQ09NJKk+OMjWQl9WitG9p\n' + + 'B6tSCQIDAQABAkA2SimBrWC2/wvauBuYqjCFwLvYiRYqZKThUS3MZlebXJiLB+Ue\n' + + '/gUifAAKIg1avttUZsHBHrop4qfJCwAI0+YRAiEA+W3NK/RaXtnRqmoUUkb59zsZ\n' + + 'UBLpvZgQPfj1MhyHDz0CIQDYhsAhPJ3mgS64NbUZmGWuuNKp5coY2GIj/zYDMJp6\n' + + 'vQIgUueLFXv/eZ1ekgz2Oi67MNCk5jeTF2BurZqNLR3MSmUCIFT3Q6uHMtsB9Eha\n' + + '4u7hS31tj1UWE+D+ADzp59MGnoftAiBeHT7gDMuqeJHPL4b+kC+gzV4FGTfhR9q3\n' + + 'tTbklZkD2A==' + +// 加密 +export function encrypt(txt) { + const encryptor = new JSEncrypt() + encryptor.setPublicKey(publicKey) // 设置公钥 + return encryptor.encrypt(txt) // 对需要加密的数据进行加密 +} + +// 解密 +export function decrypt(txt) { + const encryptor = new JSEncrypt() + encryptor.setPrivateKey(privateKey) + return encryptor.decrypt(txt) +} + diff --git a/ruoyi-ui/src/views/login.vue b/ruoyi-ui/src/views/login.vue index 880af8d3..86796878 100644 --- a/ruoyi-ui/src/views/login.vue +++ b/ruoyi-ui/src/views/login.vue @@ -56,6 +56,7 @@