Skip to content

Commit

Permalink
防止jsencrypt非压缩模块打包的时候导致的安全问题
Browse files Browse the repository at this point in the history
Signed-off-by: ArvinHuang <[email protected]>
  • Loading branch information
idwenwen committed Jul 13, 2023
1 parent a31003d commit 613a7ae
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
1 change: 1 addition & 0 deletions resources-front-end/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
<body>
<div id="app"></div>
<!-- built files will be auto injected -->
<script src="./static/jsencrypt.min.js"></script>
</body>
</html>
2 changes: 0 additions & 2 deletions resources-front-end/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
"file-saver": "^2.0.1",
"hmac_sha1": "^0.1.1",
"js-cookie": "2.2.0",
"jsencrypt": "^3.2.1",
"jsencrypter": "^1.2.1",
"jszip": "^3.7.1",
"lodash": "^4.17.21",
"mockjs": "1.0.1-beta3",
Expand Down
16 changes: 9 additions & 7 deletions resources-front-end/src/utils/encrypt.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { JSEncrypt } from 'jsencrypt'

export default function rsa(publicKet, origin) {
const jsencrypt = new JSEncrypt()
jsencrypt.setPublicKey(publicKet)
return jsencrypt.encrypt(origin)
}
export default function rsa(publicKet, origin) {
if (window.JSEncrypt) {
const jsencrypt = new window.JSEncrypt()
jsencrypt.setPublicKey(publicKet)
return jsencrypt.encrypt(origin)
} else {
return origin
}
}
2 changes: 2 additions & 0 deletions resources-front-end/static/jsencrypt.min.js

Large diffs are not rendered by default.

0 comments on commit 613a7ae

Please sign in to comment.