From 6bbbe312a2b529fc06ceea4f82cdb09360cb5db8 Mon Sep 17 00:00:00 2001 From: ibuler Date: Tue, 13 Sep 2022 11:26:26 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E5=8A=A0=E5=AF=86?= =?UTF-8?q?=EF=BC=8C=E6=B2=A1=E6=9C=89rsa=E5=88=99=E4=B8=8D=E5=8A=A0?= =?UTF-8?q?=E5=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/static/js/jumpserver.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/apps/static/js/jumpserver.js b/apps/static/js/jumpserver.js index c95c06c2c..b6bb6c6a4 100644 --- a/apps/static/js/jumpserver.js +++ b/apps/static/js/jumpserver.js @@ -1549,10 +1549,13 @@ function encryptPassword(password) { if (!password) { return '' } - const aesKey = (Math.random() + 1).toString(36).substring(2) // public key 是 base64 存储的 - const rsaPublicKeyText = getCookie('jms_public_key') - .replaceAll('"', '') + let rsaPublicKeyText = getCookie('jms_public_key') + if (!rsaPublicKeyText) { + return password + } + const aesKey = (Math.random() + 1).toString(36).substring(2) + rsaPublicKeyText = rsaPublicKeyText.replaceAll('"', '') const rsaPublicKey = atob(rsaPublicKeyText) const keyCipher = rsaEncrypt(aesKey, rsaPublicKey) const passwordCipher = aesEncrypt(password, aesKey)