第一次提交
This commit is contained in:
@@ -0,0 +1,108 @@
|
||||
## v2.0.4
|
||||
- 添加index.d.ts声明文件
|
||||
- 优化_doCryptBlock方法,还原为源库的二阶数组写法
|
||||
- 在DevEco Studio: NEXT Beta1-5.0.3.806, SDK:API12 Release(5.0.0.66)上验证通过
|
||||
|
||||
## v2.0.4-rc.1
|
||||
- 添加index.d.ts声明文件
|
||||
|
||||
## v2.0.4-rc.0
|
||||
- 优化_doCryptBlock方法,还原为源库的二阶数组写法
|
||||
|
||||
## v2.0.3
|
||||
- 适配源库4.2.0版本,更改PBKDF2的默认哈希算法和迭代,以通过使用默认配置来防止弱安全性。
|
||||
- 支持blowfish加密
|
||||
- 修复不兼容API9问题
|
||||
- 优化hasOwn方法
|
||||
|
||||
## v2.0.3-rc.1
|
||||
- 适配源库4.2.0版本,更改PBKDF2的默认哈希算法和迭代,以通过使用默认配置来防止弱安全性。
|
||||
- 支持blowfish加密
|
||||
|
||||
## v2.0.3-rc.0
|
||||
- 修复不兼容API9问题
|
||||
|
||||
## v2.0.2
|
||||
- ArkTs语法规则整改
|
||||
|
||||
## v2.0.1
|
||||
- 支持export default和export两种引入方式
|
||||
- 适配DevEco Studio: 4.0 Canary1(4.0.3.212)
|
||||
- 适配SDK: API 10 Release(4.0.8.3)
|
||||
|
||||
## v2.0.0
|
||||
- 包管理工具由npm切换为ohpm
|
||||
- 适配DevEco Studio: 3.1 Beta2(3.1.0.400)
|
||||
- 适配SDK: API9 Release(3.2.11.9)
|
||||
|
||||
## v1.0.6
|
||||
|
||||
1. 完善DevEco Studio 3.1 Beta1及以上版本适配
|
||||
2. 去掉polyfill接口,采用原生sdk接口
|
||||
|
||||
## v1.0.5
|
||||
|
||||
1. 适配DevEco Studio 3.1 Beta1及以上版本
|
||||
|
||||
## v1.0.4
|
||||
|
||||
1. 修复加解密不可逆的问题
|
||||
|
||||
## v1.0.3
|
||||
|
||||
1. 修复加密算法中特殊字符以及中文字符加密错误的问题
|
||||
|
||||
## v1.0.2
|
||||
|
||||
1. 适配API9
|
||||
|
||||
2. 直接引用源库使用,删除本库的绝大部分逻辑,仅将客制化的部分抽出作为lib
|
||||
|
||||
## v1.0.1
|
||||
|
||||
- 已实现功能
|
||||
1. sha224
|
||||
2. sha384
|
||||
3. sha3
|
||||
4. hmac-sha224
|
||||
5. hmac-sha384
|
||||
6. hmac-sha3
|
||||
7. pbkdf2
|
||||
8. aes
|
||||
9. tripledes
|
||||
10. rc4
|
||||
11. rabbit
|
||||
12. rabbit-legacy
|
||||
13. evpkdf
|
||||
14. format-openssl
|
||||
15. format-hex
|
||||
16. enc-latin1
|
||||
17. enc-utf8
|
||||
18. enc-hex
|
||||
19. enc-utf16
|
||||
20. enc-base64
|
||||
21. mode-cfb
|
||||
22. mode-ctr
|
||||
23. mode-ctr-gladman
|
||||
24. mode-ofb
|
||||
25. mode-ecb
|
||||
26. pad-pkcs7
|
||||
27. pad-ansix923
|
||||
28. pad-iso10126
|
||||
29. pad-iso97971
|
||||
30. pad-zeropadding
|
||||
31. pad-nopadding
|
||||
|
||||
## v1.0.0
|
||||
|
||||
- 已实现功能
|
||||
1. md5
|
||||
2. sha1
|
||||
3. sha256
|
||||
4. sha512
|
||||
5. ripemd160
|
||||
6. hmac-md5
|
||||
7. hmac-sha1
|
||||
8. hmac-sha256
|
||||
9. hmac-sha512
|
||||
10. hmac-ripemd160
|
||||
@@ -0,0 +1,24 @@
|
||||
# License
|
||||
|
||||
[The MIT License (MIT)](http://opensource.org/licenses/MIT)
|
||||
|
||||
Copyright (c) 2009-2013 Jeff Mott
|
||||
Copyright (c) 2013-2016 Evan Vosberg
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
@@ -0,0 +1,35 @@
|
||||
OPEN SOURCE SOFTWARE NOTICE
|
||||
|
||||
Please note we provide an open source software notice for the third party open source software along with this software and/or this software component (in the following just “this SOFTWARE”). The open source software licenses are granted by the respective right holders.
|
||||
|
||||
Warranty Disclaimer
|
||||
THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
|
||||
|
||||
Copyright Notice and License Texts
|
||||
|
||||
----------------------------------------------------------------------
|
||||
Software: crypto-js 4.1.1
|
||||
|
||||
Copyright notice:
|
||||
[The MIT License (MIT)](http://opensource.org/licenses/MIT)
|
||||
|
||||
Copyright (c) 2009-2013 Jeff Mott
|
||||
Copyright (c) 2013-2016 Evan Vosberg
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
@@ -0,0 +1,21 @@
|
||||
[
|
||||
{
|
||||
"Name": "crypto-js",
|
||||
"License": "MIT",
|
||||
"License File": " LICENSE ",
|
||||
"Version Number": "4.1.1",
|
||||
"Owner" : "xiafeng@huawei.com",
|
||||
"Upstream URL": "https://github.com/brix/crypto-js",
|
||||
"Description": "JavaScript library of crypto standards"
|
||||
},
|
||||
|
||||
{
|
||||
"Name": "DefinitelyTyped",
|
||||
"License": "MIT",
|
||||
"License File": " LICENSE ",
|
||||
"Version Number": "4.2.2",
|
||||
"Owner" : "xiafeng@huawei.com",
|
||||
"Upstream URL": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/crypto-js",
|
||||
"Description": "The repository for high quality TypeScript type definitions."
|
||||
},
|
||||
]
|
||||
@@ -0,0 +1,153 @@
|
||||
# crypto-js
|
||||
|
||||
## 简介
|
||||
本软件是移植开源软件 [crypto-js](https://github.com/brix/crypto-js) 源码在OpenHarmony上进行功能适配,在OpenHarmony上已支持原库crypto-js的功能,目前crypto-js已支持的算法有:MD5、SHA-1、SHA-256、HMAC、HMAC-MD5、HMAC-SHA1、HMAC-SHA256、PBKDF2、AES、RC4、DES等。
|
||||
|
||||

|
||||
|
||||
## 下载安装
|
||||
```shell
|
||||
ohpm install @ohos/crypto-js
|
||||
```
|
||||
OpenHarmony ohpm 环境配置等更多内容,请参考[如何安装 OpenHarmony ohpm 包](https://gitee.com/openharmony-tpc/docs/blob/master/OpenHarmony_har_usage.md)
|
||||
## 使用说明
|
||||
1. 引入依赖
|
||||
```
|
||||
最新版本支持
|
||||
import { CryptoJS } from '@ohos/crypto-js' 或者
|
||||
import CryptoJS from '@ohos/crypto-js'
|
||||
```
|
||||
2. md5算法使用
|
||||
|
||||
md5信息摘要算法(英语:md5 Message-Digest Algorithm),一种被广泛使用的密码散列函数,可以产生出一个128位(16字节)的散列值(hash value),用于确保信息传输完整一致。
|
||||
|
||||
md5特点:
|
||||
1. 不可逆性 --- 根据 MD5 值计算不出原始数据
|
||||
2. 唯一性 --- 不同原始数据会有不同的 MD5 值
|
||||
|
||||
md5算法在本库的使用:
|
||||
```
|
||||
//第一步在需要使用到的页面,导入CryptoJS
|
||||
import { CryptoJS } from '@ohos/crypto-js'
|
||||
//第二步在需要使用到md5的业务逻辑,调用md5算法
|
||||
var hash = CryptoJS.MD5("123456") //传参是需要加密的内容,返回值是加密后的数据
|
||||
```
|
||||
3. aes算法使用
|
||||
|
||||
AES算法全称Advanced Encryption Standard,又称Rijndael加密法,是美国联邦政府采用的一种区块加密标准。
|
||||
|
||||
AES是对称加密,所以加密解密都需要用到同一个秘钥。
|
||||
|
||||
AES算法在本库的使用:
|
||||
```
|
||||
//第一步在需要使用到的页面,导入CryptoJS
|
||||
import { CryptoJS } from '@ohos/crypto-js'
|
||||
//第二步定义加密解密需要用到的key
|
||||
var key = 'secret key 1234'
|
||||
//第三步在需要使用AES加密的业务逻辑,调用AES加密
|
||||
var encrypted = CryptoJS.AES.encrypt('hello world', key).toString() //传参为加密内容及秘钥
|
||||
//第四步在需要把上面的加密块解密的业务逻辑,调用AES解密,注意key必须相同
|
||||
var decrypted = CryptoJS.AES.decrypt(encrypted, key) //传参为加密后的内容及秘钥
|
||||
```
|
||||
其他加密算法使用方式,如sha1、sha256、sha224、sha512、sha384、sha3、ripemd160、hmac-md5、hmac-sha1、hmac-sha256、hmac-sha224、hmac-sha512、hmac-sha384、hmac-sha3、hmac-ripemd160
|
||||
、pbkdf2、aes、tripledes、rc4、rabbit、rabbit-legacy、evpkdf、des、triple-des、format-openssl、format-hex、enc-latin1、enc-utf8、enc-hex、enc-utf16、enc-base64、
|
||||
mode-cfb、mode-ctr、mode-ctr-gladman、mode-ofb、mode-ecb、pad-pkcs7、pad-ansix923、pad-iso10126、pad-iso97971、pad-zeropadding、pad-nopadding。
|
||||
|
||||
更多使用方法请参照 [demo](https://gitee.com/openharmony-sig/crypto-js/blob/master/entry/src/main/ets/pages/Index.ets) 和 [XTS](https://gitee.com/openharmony-sig/crypto-js/tree/master/entry/src/ohosTest/ets/test) 及 [参考原库使用文档](https://cryptojs.gitbook.io/docs/)
|
||||
|
||||
|
||||
## 接口列表
|
||||
|
||||
- `crypto-js/md5`
|
||||
- `crypto-js/sha1`
|
||||
- `crypto-js/sha256`
|
||||
- `crypto-js/sha224`
|
||||
- `crypto-js/sha512`
|
||||
- `crypto-js/sha384`
|
||||
- `crypto-js/sha3`
|
||||
- `crypto-js/ripemd160`
|
||||
------
|
||||
|
||||
- `crypto-js/hmac-md5`
|
||||
- `crypto-js/hmac-sha1`
|
||||
- `crypto-js/hmac-sha256`
|
||||
- `crypto-js/hmac-sha224`
|
||||
- `crypto-js/hmac-sha512`
|
||||
- `crypto-js/hmac-sha384`
|
||||
- `crypto-js/hmac-sha3`
|
||||
- `crypto-js/hmac-ripemd160`
|
||||
|
||||
------
|
||||
|
||||
- `crypto-js/pbkdf2`
|
||||
|
||||
------
|
||||
|
||||
- `crypto-js/aes`
|
||||
- `crypto-js/tripledes`
|
||||
- `crypto-js/rc4`
|
||||
- `crypto-js/rabbit`
|
||||
- `crypto-js/rabbit-legacy`
|
||||
- `crypto-js/evpkdf`
|
||||
- `crypto-js/des`
|
||||
- `crypto-js/triple-des`
|
||||
|
||||
------
|
||||
|
||||
- `crypto-js/format-openssl`
|
||||
- `crypto-js/format-hex`
|
||||
|
||||
------
|
||||
|
||||
- `crypto-js/enc-latin1`
|
||||
- `crypto-js/enc-utf8`
|
||||
- `crypto-js/enc-hex`
|
||||
- `crypto-js/enc-utf16`
|
||||
- `crypto-js/enc-base64`
|
||||
|
||||
------
|
||||
|
||||
- `crypto-js/mode-cfb`
|
||||
- `crypto-js/mode-ctr`
|
||||
- `crypto-js/mode-ctr-gladman`
|
||||
- `crypto-js/mode-ofb`
|
||||
- `crypto-js/mode-ecb`
|
||||
|
||||
------
|
||||
|
||||
- `crypto-js/pad-pkcs7`
|
||||
- `crypto-js/pad-ansix923`
|
||||
- `crypto-js/pad-iso10126`
|
||||
- `crypto-js/pad-iso97971`
|
||||
- `crypto-js/pad-zeropadding`
|
||||
- `crypto-js/pad-nopadding`
|
||||
|
||||
## 约束与限制
|
||||
|
||||
在下述版本验证通过:
|
||||
- DevEco Studio: NEXT Beta1-5.0.3.806, SDK:API12 Release(5.0.0.66)
|
||||
- DevEco Studio : 5.0.3.122, SDK: API12 (5.0.0.17)
|
||||
- DevEco Studio : 4.1.3.600, SDK: API11 (4.1.0.67)
|
||||
|
||||
## 目录结构
|
||||
````
|
||||
|---- crypto-js
|
||||
| |---- entry # 示例代码文件夹
|
||||
| |---- crypto # crypto-js库文件夹
|
||||
| |---- index.ts # 对外接口
|
||||
| |---- src
|
||||
| |---- main
|
||||
| |---- ets
|
||||
| |---- components
|
||||
| |---- crypto.ts # 加密封装类
|
||||
| |---- README.md # 安装使用方法
|
||||
````
|
||||
|
||||
## 贡献代码
|
||||
使用过程中发现任何问题都可以提 [Issue](https://gitee.com/openharmony-sig/crypto-js/issues) 给我们,当然,我们也非常欢迎你给我们发 [PR](https://gitee.com/openharmony-sig/crypto-js/pulls) 。
|
||||
|
||||
## 开源协议
|
||||
本项目基于 [MIT License](https://gitee.com/openharmony-sig/crypto-js/blob/master/LICENSE) ,请自由地享受和参与开源。
|
||||
|
||||
## 遗留问题
|
||||
- pbkdf2算法性能问题
|
||||
@@ -0,0 +1 @@
|
||||
string page_show 0x02000000
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"apiType": "stageMode",
|
||||
"buildOption": {
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"name": "default"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
|
||||
export { harTasks } from '@ohos/hvigor-ohos-plugin';
|
||||
+1802
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the MIT License, (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://opensource.org/licenses/MIT
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// import CryptoJS from './src/main/js/core';
|
||||
import CryptoJS from "./src/main/js/crypto-js"
|
||||
|
||||
export default CryptoJS;
|
||||
|
||||
export { CryptoJS };
|
||||
@@ -0,0 +1 @@
|
||||
{"types":"index.d.ts","keywords":["crypto-js","OpenHarmony","HarmonyOS"],"author":"hihope","description":"The encryption algorithm class library can be very convenient to perform the encryption and decryption operations it supports in the front end. Currently, the algorithms supported by crypto-js are: MD5, SHA-1, SHA-256, HMAC, HMAC-MD5, HMAC-SHA1, HMAC-SHA256, PBKDF2, etc.","ohos":{"org":"opensource"},"main":"index.ts","repository":"https://gitee.com/openharmony-sig/crypto-js","type":"module","version":"2.0.4","dependencies":{},"tags":["Tools","Security"],"license":"MIT","devDependencies":{},"name":"@ohos/crypto-js","metadata":{"sourceRoots":["./src/main"]},"compatibleSdkVersion":9,"compatibleSdkType":"OpenHarmony","obfuscated":false}
|
||||
+8025
File diff suppressed because it is too large
Load Diff
+22
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the MIT License, (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://opensource.org/licenses/MIT
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export function hasOwn(obj,value){
|
||||
for (let key in obj) {
|
||||
if (key === value) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"app": {
|
||||
"bundleName": "cn.openharmony.crypto",
|
||||
"versionCode": 1000002,
|
||||
"versionName": "2.0.3",
|
||||
"minAPIVersion": 9,
|
||||
"targetAPIVersion": 10,
|
||||
"apiReleaseType": "Release",
|
||||
"compileSdkVersion": "4.0.10.16",
|
||||
"compileSdkType": "OpenHarmony",
|
||||
"appEnvironments": [],
|
||||
"bundleType": "app"
|
||||
},
|
||||
"module": {
|
||||
"name": "library",
|
||||
"type": "har",
|
||||
"deviceTypes": [
|
||||
"default",
|
||||
"tablet"
|
||||
],
|
||||
"packageName": "@ohos/crypto-js",
|
||||
"installationFree": false,
|
||||
"virtualMachine": "ark9.0.0.0",
|
||||
"compileMode": "esmodule",
|
||||
"dependencies": []
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "page_show",
|
||||
"value": "page from npm package"
|
||||
}
|
||||
]
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "page_show",
|
||||
"value": "page from npm package"
|
||||
}
|
||||
]
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "page_show",
|
||||
"value": "page from npm package"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user