Skip to content

Commit

Permalink
Merge pull request #63 from vusion/task-2817277092559616-cw_cryptojs_…
Browse files Browse the repository at this point in the history
…library-hanshijie-240301

feat: 新增sjcl库版本的base64算法
  • Loading branch information
ncqwer authored Mar 4, 2024
2 parents 765a83c + 8c1d8a6 commit dd3efd1
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 6 deletions.
8 changes: 8 additions & 0 deletions packages/cw/cw_cryptojs_library/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## 1.0.2

Associated Task: [#281727](https://projectmanage.netease-official.lcap.163yun.com/dashboard/TaskDetail?id=2817277092559616)

### ✨Features

- [bbaa239](https://github.com/vusion/cloud-ui-materials/commit/bbaa23939f08ec7397ff463caf9736cf63c3a291) Thanks [ncqwer](https://github.com/ncqwer) ! - 新增sjcl库版本的base64算法

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- name: base64Withsjcl
description: 使用sjcl库完成utf8的base64
type: both
belong: logic
labels: [Runtime]
10 changes: 10 additions & 0 deletions packages/cw/cw_cryptojs_library/logics/base64Withsjcl/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import sjcl from 'sjcl';

// doc: https://github.com/bitwiseshiftleft/sjcl
/**
* @param {string} string <true> 原始字符串
* @returns {string} 加密后结果
*/
export default (string) => {
return sjcl.codec.base64url.fromBits(sjcl.codec.utf8String.toBits(string));
};
2 changes: 2 additions & 0 deletions packages/cw/cw_cryptojs_library/logics/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import encryptByDes from './encryptByDes'
import encryptSha256 from './encryptSha256'
import encryptDataWithSalt from './encryptDataWithSalt'
import decryptDataWithSalt from './decryptDataWithSalt'
import base64Withsjcl from './base64Withsjcl'
// LOGIC IMPORTS
UtilsLogics.install = function (Vue, option = {}) {
Vue.prototype.$library = Vue.prototype.$library || {}
Expand All @@ -13,6 +14,7 @@ UtilsLogics.install = function (Vue, option = {}) {
Vue.prototype.$library[`${$libraryName}`].encryptSha256=encryptSha256
Vue.prototype.$library[`${$libraryName}`].encryptDataWithSalt=encryptDataWithSalt
Vue.prototype.$library[`${$libraryName}`].decryptDataWithSalt=decryptDataWithSalt
Vue.prototype.$library[`${$libraryName}`].base64Withsjcl=base64Withsjcl
// LOGIC USE
window.__$libraryEncryptSha256 = encryptSha256
}
Expand Down
6 changes: 3 additions & 3 deletions packages/cw/cw_cryptojs_library/manifest
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Plugin-Version: 1.0.0
Library-Type: Frontend
Metadata-File: usage.json
packages/extension/[email protected].1/dist-theme/demo.html: dist-theme/demo.html
packages/extension/[email protected].1/dist-theme/index.js: dist-theme/index.js
packages/extension/[email protected].1/dist-theme/index.js.map: dist-theme/index.js.map
packages/extension/[email protected].2/dist-theme/demo.html: dist-theme/demo.html
packages/extension/[email protected].2/dist-theme/index.js: dist-theme/index.js
packages/extension/[email protected].2/dist-theme/index.js.map: dist-theme/index.js.map
7 changes: 4 additions & 3 deletions packages/cw/cw_cryptojs_library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "cw_cryptojs_library",
"title": "前端加密依赖库",
"description": "",
"version": "1.0.1",
"version": "1.0.2",
"main": "./index.js",
"author": "",
"repository": "",
Expand Down Expand Up @@ -49,6 +49,7 @@
"inited": true
},
"dependencies": {
"crypto-js": "^4.2.0"
"crypto-js": "^4.2.0",
"sjcl": "^1.0.8"
}
}
}

0 comments on commit dd3efd1

Please sign in to comment.