Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
c8b2fc6f
D
Docs
项目概览
OpenHarmony
/
Docs
1 年多 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
c8b2fc6f
编写于
10月 18, 2022
作者:
C
CheungVane
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
将var改为let
Signed-off-by:
N
zhangwenzhi
<
zhangwenzhi3@huawei.com
>
上级
7bfb07a6
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
122 addition
and
122 deletion
+122
-122
zh-cn/application-dev/reference/apis/js-apis-huks.md
zh-cn/application-dev/reference/apis/js-apis-huks.md
+122
-122
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-huks.md
浏览文件 @
c8b2fc6f
...
...
@@ -81,8 +81,8 @@ generateKeyItem(keyAlias: string, options: HuksOptions, callback: AsyncCallback\
```
js
/* 以生成ECC256密钥为例 */
var
keyAlias
=
'
keyAlias
'
;
var
properties
=
new
Array
();
let
keyAlias
=
'
keyAlias
'
;
let
properties
=
new
Array
();
properties
[
0
]
=
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_ALGORITHM
,
value
:
huks
.
HuksKeyAlg
.
HUKS_ALG_ECC
...
...
@@ -101,7 +101,7 @@ properties[3] = {
tag
:
huks
.
HuksTag
.
HUKS_TAG_DIGEST
,
value
:
huks
.
HuksKeyDigest
.
HUKS_DIGEST_SHA256
};
var
options
=
{
let
options
=
{
properties
:
properties
};
try
{
...
...
@@ -136,8 +136,8 @@ generateKeyItem(keyAlias: string, options: HuksOptions) : Promise\<void>
```
js
/* 以生成ECC256密钥为例 */
var
keyAlias
=
'
keyAlias
'
;
var
properties
=
new
Array
();
let
keyAlias
=
'
keyAlias
'
;
let
properties
=
new
Array
();
properties
[
0
]
=
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_ALGORITHM
,
value
:
huks
.
HuksKeyAlg
.
HUKS_ALG_ECC
...
...
@@ -156,7 +156,7 @@ properties[3] = {
tag
:
huks
.
HuksTag
.
HUKS_TAG_DIGEST
,
value
:
huks
.
HuksKeyDigest
.
HUKS_DIGEST_SHA256
};
var
options
=
{
let
options
=
{
properties
:
properties
};
try
{
...
...
@@ -192,8 +192,8 @@ deleteKeyItem(keyAlias: string, options: HuksOptions, callback: AsyncCallback\<v
```
js
/* 此处options选择emptyOptions传空 */
var
keyAlias
=
'
keyAlias
'
;
var
emptyOptions
=
{
let
keyAlias
=
'
keyAlias
'
;
let
emptyOptions
=
{
properties
:
[]
};
try
{
...
...
@@ -228,8 +228,8 @@ deleteKeyItem(keyAlias: string, options: HuksOptions) : Promise\<void>
```
js
/* 此处options选择emptyOptions传空 */
var
keyAlias
=
'
keyAlias
'
;
var
emptyOptions
=
{
let
keyAlias
=
'
keyAlias
'
;
let
emptyOptions
=
{
properties
:
[]
};
try
{
...
...
@@ -269,10 +269,10 @@ getSdkVersion(options: HuksOptions) : string
```
js
/* 此处options选择emptyOptions传空 */
var
emptyOptions
=
{
let
emptyOptions
=
{
properties
:
[]
};
var
result
=
huks
.
getSdkVersion
(
emptyOptions
);
let
result
=
huks
.
getSdkVersion
(
emptyOptions
);
```
## huks.importKeyItem<sup>9+</sup>
...
...
@@ -295,16 +295,16 @@ importKeyItem(keyAlias: string, options: HuksOptions, callback: AsyncCallback\<v
```
js
/* 以导入AES256密钥为例 */
var
plainTextSize32
=
makeRandomArr
(
32
);
let
plainTextSize32
=
makeRandomArr
(
32
);
function
makeRandomArr
(
size
)
{
var
arr
=
new
Uint8Array
(
size
);
for
(
var
i
=
0
;
i
<
size
;
i
++
)
{
let
arr
=
new
Uint8Array
(
size
);
for
(
let
i
=
0
;
i
<
size
;
i
++
)
{
arr
[
i
]
=
Math
.
floor
(
Math
.
random
()
*
10
);
}
return
arr
;
};
var
keyAlias
=
'
keyAlias
'
;
var
properties
=
new
Array
();
let
keyAlias
=
'
keyAlias
'
;
let
properties
=
new
Array
();
properties
[
0
]
=
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_ALGORITHM
,
value
:
huks
.
HuksKeyAlg
.
HUKS_ALG_AES
...
...
@@ -326,7 +326,7 @@ properties[4] = {
tag
:
huks
.
HuksTag
.
HUKS_TAG_BLOCK_MODE
,
value
:
huks
.
HuksCipherMode
.
HUKS_MODE_ECB
};
var
options
=
{
let
options
=
{
properties
:
properties
,
inData
:
plainTextSize32
};
...
...
@@ -362,19 +362,19 @@ importKeyItem(keyAlias: string, options: HuksOptions) : Promise\<void>
```
js
/* 以导入AES128为例 */
var
plainTextSize32
=
makeRandomArr
(
32
);
let
plainTextSize32
=
makeRandomArr
(
32
);
function
makeRandomArr
(
size
)
{
var
arr
=
new
Uint8Array
(
size
);
for
(
var
i
=
0
;
i
<
size
;
i
++
)
{
let
arr
=
new
Uint8Array
(
size
);
for
(
let
i
=
0
;
i
<
size
;
i
++
)
{
arr
[
i
]
=
Math
.
floor
(
Math
.
random
()
*
10
);
}
return
arr
;
};
/*第一步:生成密钥*/
var
keyAlias
=
'
keyAlias
'
;
var
properties
=
new
Array
();
let
keyAlias
=
'
keyAlias
'
;
let
properties
=
new
Array
();
properties
[
0
]
=
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_ALGORITHM
,
value
:
huks
.
HuksKeyAlg
.
HUKS_ALG_AES
...
...
@@ -395,7 +395,7 @@ properties[4] = {
tag
:
huks
.
HuksTag
.
HUKS_TAG_BLOCK_MODE
,
value
:
huks
.
HuksCipherMode
.
HUKS_MODE_ECB
};
var
huksoptions
=
{
let
huksoptions
=
{
properties
:
properties
,
inData
:
plainTextSize32
};
...
...
@@ -437,11 +437,11 @@ let versionInfo = stringToUint8Array('version_info');
let
keyAliasString
=
"
key attest
"
;
function
stringToUint8Array
(
str
)
{
var
arr
=
[];
for
(
var
i
=
0
,
j
=
str
.
length
;
i
<
j
;
++
i
)
{
let
arr
=
[];
for
(
let
i
=
0
,
j
=
str
.
length
;
i
<
j
;
++
i
)
{
arr
.
push
(
str
.
charCodeAt
(
i
));
}
var
tmpUint8Array
=
new
Uint8Array
(
arr
);
let
tmpUint8Array
=
new
Uint8Array
(
arr
);
return
tmpUint8Array
;
}
...
...
@@ -564,11 +564,11 @@ let versionInfo = stringToUint8Array('version_info');
let
keyAliasString
=
"
key attest
"
;
function
stringToUint8Array
(
str
)
{
var
arr
=
[];
for
(
var
i
=
0
,
j
=
str
.
length
;
i
<
j
;
++
i
)
{
let
arr
=
[];
for
(
let
i
=
0
,
j
=
str
.
length
;
i
<
j
;
++
i
)
{
arr
.
push
(
str
.
charCodeAt
(
i
));
}
var
tmpUint8Array
=
new
Uint8Array
(
arr
);
let
tmpUint8Array
=
new
Uint8Array
(
arr
);
return
tmpUint8Array
;
}
...
...
@@ -683,9 +683,9 @@ importWrappedKeyItem(keyAlias: string, wrappingKeyAlias: string, options: HuksOp
```
js
import
huks
from
'
@ohos.security.huks
'
;
var
exportWrappingKey
;
var
alias1
=
"
importAlias
"
;
var
alias2
=
"
wrappingKeyAlias
"
;
let
exportWrappingKey
;
let
alias1
=
"
importAlias
"
;
let
alias2
=
"
wrappingKeyAlias
"
;
async
function
TestGenFunc
(
alias
,
options
)
{
try
{
...
...
@@ -800,13 +800,13 @@ async function TestImportWrappedKeyFunc(
* nonce1的长度(4字节) + nonce1的数据 + tag1的长度(4字节) + tag1的数据 +
* keyA长度占用的内存长度(4字节) + keyA的长度 + keyA_enc的长度(4字节) + keyA_enc的数据
*/
var
inputKey
=
new
Uint8Array
([
0x02
,
0x00
,
0x00
,
0x00
]);
let
inputKey
=
new
Uint8Array
([
0x02
,
0x00
,
0x00
,
0x00
]);
importOptions
.
inData
=
inputKey
;
await
TestImportWrappedFunc
(
alias
,
wrappingAlias
,
importOptions
);
}
function
makeGenerateOptions
()
{
var
properties
=
new
Array
();
let
properties
=
new
Array
();
properties
[
0
]
=
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_ALGORITHM
,
value
:
huks
.
HuksKeyAlg
.
HUKS_ALG_ECC
...
...
@@ -827,14 +827,14 @@ function makeGenerateOptions() {
tag
:
huks
.
HuksTag
.
HUKS_TAG_IMPORT_KEY_TYPE
,
value
:
huks
.
HuksImportKeyType
.
HUKS_KEY_TYPE_KEY_PAIR
,
};
var
options
=
{
let
options
=
{
properties
:
properties
};
return
options
;
};
function
makeImportOptions
()
{
var
properties
=
new
Array
();
let
properties
=
new
Array
();
properties
[
0
]
=
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_ALGORITHM
,
value
:
huks
.
HuksKeyAlg
.
HUKS_ALG_AES
...
...
@@ -859,15 +859,15 @@ function makeImportOptions() {
tag
:
huks
.
HuksTag
.
HUKS_TAG_UNWRAP_ALGORITHM_SUITE
,
value
:
huks
.
HuksUnwrapSuite
.
HUKS_UNWRAP_SUITE_ECDH_AES_256_GCM_NOPADDING
};
var
options
=
{
let
options
=
{
properties
:
properties
};
return
options
;
};
function
huksImportWrappedKey
()
{
var
genOptions
=
makeGenerateOptions
();
var
importOptions
=
makeImportOptions
();
let
genOptions
=
makeGenerateOptions
();
let
importOptions
=
makeImportOptions
();
TestImportWrappedKeyFunc
(
alias1
,
alias2
,
...
...
@@ -932,8 +932,8 @@ exportKeyItem(keyAlias: string, options: HuksOptions, callback: AsyncCallback\<H
```
js
/* 此处options选择emptyOptions来传空 */
var
keyAlias
=
'
keyAlias
'
;
var
emptyOptions
=
{
let
keyAlias
=
'
keyAlias
'
;
let
emptyOptions
=
{
properties
:
[]
};
try
{
...
...
@@ -974,8 +974,8 @@ exportKeyItem(keyAlias: string, options: HuksOptions) : Promise\<HuksReturnResul
```
js
/* 此处options选择emptyOptions来传空 */
var
keyAlias
=
'
keyAlias
'
;
var
emptyOptions
=
{
let
keyAlias
=
'
keyAlias
'
;
let
emptyOptions
=
{
properties
:
[]
};
try
{
...
...
@@ -1011,8 +1011,8 @@ getKeyItemProperties(keyAlias: string, options: HuksOptions, callback: AsyncCall
```
js
/* 此处options选择emptyOptions来传空 */
var
keyAlias
=
'
keyAlias
'
;
var
emptyOptions
=
{
let
keyAlias
=
'
keyAlias
'
;
let
emptyOptions
=
{
properties
:
[]
};
try
{
...
...
@@ -1053,8 +1053,8 @@ getKeyItemProperties(keyAlias: string, options: HuksOptions) : Promise\<HuksRetu
```
js
/* 此处options选择emptyOptions来传空 */
var
keyAlias
=
'
keyAlias
'
;
var
emptyOptions
=
{
let
keyAlias
=
'
keyAlias
'
;
let
emptyOptions
=
{
properties
:
[]
};
try
{
...
...
@@ -1090,8 +1090,8 @@ isKeyItemExist(keyAlias: string, options: HuksOptions, callback: AsyncCallback\<
```
js
/* 此处options选择emptyOptions来传空 */
var
keyAlias
=
'
keyAlias
'
;
var
emptyOptions
=
{
let
keyAlias
=
'
keyAlias
'
;
let
emptyOptions
=
{
properties
:
[]
};
try
{
...
...
@@ -1132,8 +1132,8 @@ isKeyItemExist(keyAlias: string, options: HuksOptions) : Promise\<boolean>
```
js
/* 此处options选择emptyOptions来传空 */
var
keyAlias
=
'
keyAlias
'
;
var
emptyOptions
=
{
let
keyAlias
=
'
keyAlias
'
;
let
emptyOptions
=
{
properties
:
[]
};
try
{
...
...
@@ -1328,21 +1328,21 @@ abort操作密钥接口,使用Callback回调异步返回结果 。
* 以下以RSA1024密钥的callback功能使用为例
*/
function
stringToUint8Array
(
str
)
{
var
arr
=
[];
for
(
var
i
=
0
,
j
=
str
.
length
;
i
<
j
;
++
i
)
{
let
arr
=
[];
for
(
let
i
=
0
,
j
=
str
.
length
;
i
<
j
;
++
i
)
{
arr
.
push
(
str
.
charCodeAt
(
i
));
}
var
tmpUint8Array
=
new
Uint8Array
(
arr
);
let
tmpUint8Array
=
new
Uint8Array
(
arr
);
return
tmpUint8Array
;
}
var
keyAlias
=
"
HuksDemoRSA
"
;
var
properties
=
new
Array
();
var
options
=
{
let
keyAlias
=
"
HuksDemoRSA
"
;
let
properties
=
new
Array
();
let
options
=
{
properties
:
properties
,
inData
:
new
Uint8Array
(
0
)
};
var
handle
;
let
handle
;
async
function
generateKey
()
{
properties
[
0
]
=
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_ALGORITHM
,
...
...
@@ -1478,21 +1478,21 @@ abort操作密钥接口,使用Promise方式异步返回结果。
* 以下以RSA1024密钥的callback功能使用为例
*/
function
stringToUint8Array
(
str
)
{
var
arr
=
[];
for
(
var
i
=
0
,
j
=
str
.
length
;
i
<
j
;
++
i
)
{
let
arr
=
[];
for
(
let
i
=
0
,
j
=
str
.
length
;
i
<
j
;
++
i
)
{
arr
.
push
(
str
.
charCodeAt
(
i
));
}
var
tmpUint8Array
=
new
Uint8Array
(
arr
);
let
tmpUint8Array
=
new
Uint8Array
(
arr
);
return
tmpUint8Array
;
}
var
keyAlias
=
"
HuksDemoRSA
"
;
var
properties
=
new
Array
();
var
options
=
{
let
keyAlias
=
"
HuksDemoRSA
"
;
let
properties
=
new
Array
();
let
options
=
{
properties
:
properties
,
inData
:
new
Uint8Array
(
0
)
};
var
handle
;
let
handle
;
async
function
generateKey
()
{
properties
[
0
]
=
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_ALGORITHM
,
...
...
@@ -1999,8 +1999,8 @@ generateKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback\<Huk
```
js
/* 以生成RSA512密钥为例 */
var
keyAlias
=
'
keyAlias
'
;
var
properties
=
new
Array
();
let
keyAlias
=
'
keyAlias
'
;
let
properties
=
new
Array
();
properties
[
0
]
=
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_ALGORITHM
,
value
:
huks
.
HuksKeyAlg
.
HUKS_ALG_RSA
...
...
@@ -2023,7 +2023,7 @@ properties[4] = {
tag
:
huks
.
HuksTag
.
HUKS_TAG_DIGEST
,
value
:
huks
.
HuksKeyDigest
.
HUKS_DIGEST_SHA256
};
var
options
=
{
let
options
=
{
properties
:
properties
};
huks
.
generateKey
(
keyAlias
,
options
,
function
(
err
,
data
){});
...
...
@@ -2056,8 +2056,8 @@ generateKey(keyAlias: string, options: HuksOptions) : Promise\<HuksResult>
```
js
/* 以生成ECC256密钥为例 */
var
keyAlias
=
'
keyAlias
'
;
var
properties
=
new
Array
();
let
keyAlias
=
'
keyAlias
'
;
let
properties
=
new
Array
();
properties
[
0
]
=
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_ALGORITHM
,
value
:
huks
.
HuksKeyAlg
.
HUKS_ALG_ECC
...
...
@@ -2076,10 +2076,10 @@ properties[3] = {
tag
:
huks
.
HuksTag
.
HUKS_TAG_DIGEST
,
value
:
huks
.
HuksKeyDigest
.
HUKS_DIGEST_SHA256
};
var
options
=
{
let
options
=
{
properties
:
properties
};
var
result
=
huks
.
generateKey
(
keyAlias
,
options
);
let
result
=
huks
.
generateKey
(
keyAlias
,
options
);
```
...
...
@@ -2105,8 +2105,8 @@ deleteKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback\<HuksR
```
js
/* 此处options选择emptyOptions传空 */
var
keyAlias
=
'
keyAlias
'
;
var
emptyOptions
=
{
let
keyAlias
=
'
keyAlias
'
;
let
emptyOptions
=
{
properties
:
[]
};
huks
.
deleteKey
(
keyAlias
,
emptyOptions
,
function
(
err
,
data
)
{});
...
...
@@ -2139,11 +2139,11 @@ deleteKey(keyAlias: string, options: HuksOptions) : Promise\<HuksResult>
```
js
/* 此处options选择emptyOptions传空 */
var
keyAlias
=
'
keyAlias
'
;
var
emptyOptions
=
{
let
keyAlias
=
'
keyAlias
'
;
let
emptyOptions
=
{
properties
:
[]
};
var
result
=
huks
.
deleteKey
(
keyAlias
,
emptyOptions
);
let
result
=
huks
.
deleteKey
(
keyAlias
,
emptyOptions
);
```
...
...
@@ -2169,16 +2169,16 @@ importKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback\<HuksR
```
js
/* 以导入AES256密钥为例 */
var
plainTextSize32
=
makeRandomArr
(
32
);
let
plainTextSize32
=
makeRandomArr
(
32
);
function
makeRandomArr
(
size
)
{
var
arr
=
new
Uint8Array
(
size
);
for
(
var
i
=
0
;
i
<
size
;
i
++
)
{
let
arr
=
new
Uint8Array
(
size
);
for
(
let
i
=
0
;
i
<
size
;
i
++
)
{
arr
[
i
]
=
Math
.
floor
(
Math
.
random
()
*
10
);
}
return
arr
;
};
var
keyAlias
=
'
keyAlias
'
;
var
properties
=
new
Array
();
let
keyAlias
=
'
keyAlias
'
;
let
properties
=
new
Array
();
properties
[
0
]
=
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_ALGORITHM
,
value
:
huks
.
HuksKeyAlg
.
HUKS_ALG_AES
...
...
@@ -2200,7 +2200,7 @@ properties[4] = {
tag
:
huks
.
HuksTag
.
HUKS_TAG_BLOCK_MODE
,
value
:
huks
.
HuksCipherMode
.
HUKS_MODE_ECB
};
var
options
=
{
let
options
=
{
properties
:
properties
,
inData
:
plainTextSize32
};
...
...
@@ -2234,19 +2234,19 @@ importKey(keyAlias: string, options: HuksOptions) : Promise\<HuksResult>
```
js
/* 以导入AES128为例 */
var
plainTextSize32
=
makeRandomArr
(
32
);
let
plainTextSize32
=
makeRandomArr
(
32
);
function
makeRandomArr
(
size
)
{
var
arr
=
new
Uint8Array
(
size
);
for
(
var
i
=
0
;
i
<
size
;
i
++
)
{
let
arr
=
new
Uint8Array
(
size
);
for
(
let
i
=
0
;
i
<
size
;
i
++
)
{
arr
[
i
]
=
Math
.
floor
(
Math
.
random
()
*
10
);
}
return
arr
;
};
/*第一步:生成密钥*/
var
keyAlias
=
'
keyAlias
'
;
var
properties
=
new
Array
();
let
keyAlias
=
'
keyAlias
'
;
let
properties
=
new
Array
();
properties
[
0
]
=
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_ALGORITHM
,
value
:
huks
.
HuksKeyAlg
.
HUKS_ALG_AES
...
...
@@ -2267,11 +2267,11 @@ properties[4] = {
tag
:
huks
.
HuksTag
.
HUKS_TAG_BLOCK_MODE
,
value
:
huks
.
HuksCipherMode
.
HUKS_MODE_ECB
};
var
huksoptions
=
{
let
huksoptions
=
{
properties
:
properties
,
inData
:
plainTextSize32
};
var
result
=
huks
.
importKey
(
keyAlias
,
huksoptions
);
let
result
=
huks
.
importKey
(
keyAlias
,
huksoptions
);
```
...
...
@@ -2297,8 +2297,8 @@ exportKey(keyAlias: string, options: HuksOptions, callback: AsyncCallback\<HuksR
```
js
/* 此处options选择emptyOptions来传空 */
var
keyAlias
=
'
keyAlias
'
;
var
emptyOptions
=
{
let
keyAlias
=
'
keyAlias
'
;
let
emptyOptions
=
{
properties
:
[]
};
huks
.
exportKey
(
keyAlias
,
emptyOptions
,
function
(
err
,
data
){});
...
...
@@ -2331,11 +2331,11 @@ exportKey(keyAlias: string, options: HuksOptions) : Promise\<HuksResult>
```
js
/* 此处options选择emptyOptions来传空 */
var
keyAlias
=
'
keyAlias
'
;
var
emptyOptions
=
{
let
keyAlias
=
'
keyAlias
'
;
let
emptyOptions
=
{
properties
:
[]
};
var
result
=
huks
.
exportKey
(
keyAlias
,
emptyOptions
);
let
result
=
huks
.
exportKey
(
keyAlias
,
emptyOptions
);
```
...
...
@@ -2361,8 +2361,8 @@ getKeyProperties(keyAlias: string, options: HuksOptions, callback: AsyncCallback
```
js
/* 此处options选择emptyOptions来传空 */
var
keyAlias
=
'
keyAlias
'
;
var
emptyOptions
=
{
let
keyAlias
=
'
keyAlias
'
;
let
emptyOptions
=
{
properties
:
[]
};
huks
.
getKeyProperties
(
keyAlias
,
emptyOptions
,
function
(
err
,
data
){});
...
...
@@ -2395,11 +2395,11 @@ getKeyProperties(keyAlias: string, options: HuksOptions) : Promise\<HuksResult>
```
js
/* 此处options选择emptyOptions来传空 */
var
keyAlias
=
'
keyAlias
'
;
var
emptyOptions
=
{
let
keyAlias
=
'
keyAlias
'
;
let
emptyOptions
=
{
properties
:
[]
};
var
result
=
huks
.
getKeyProperties
(
keyAlias
,
emptyOptions
);
let
result
=
huks
.
getKeyProperties
(
keyAlias
,
emptyOptions
);
```
...
...
@@ -2425,8 +2425,8 @@ isKeyExist(keyAlias: string, options: HuksOptions, callback: AsyncCallback\<bool
```
js
/* 此处options选择emptyOptions来传空 */
var
keyAlias
=
'
keyAlias
'
;
var
emptyOptions
=
{
let
keyAlias
=
'
keyAlias
'
;
let
emptyOptions
=
{
properties
:
[]
};
huks
.
isKeyExist
(
keyAlias
,
emptyOptions
,
function
(
err
,
data
){});
...
...
@@ -2459,11 +2459,11 @@ isKeyExist(keyAlias: string, options: HuksOptions) : Promise\<boolean>
```
js
/* 此处options选择emptyOptions来传空 */
var
keyAlias
=
'
keyAlias
'
;
var
emptyOptions
=
{
let
keyAlias
=
'
keyAlias
'
;
let
emptyOptions
=
{
properties
:
[]
};
var
result
=
huks
.
isKeyExist
(
keyAlias
,
emptyOptions
);
let
result
=
huks
.
isKeyExist
(
keyAlias
,
emptyOptions
);
```
## huks.init<sup>(deprecated)</sup>
...
...
@@ -2640,14 +2640,14 @@ abort操作密钥接口,使用Callback回调异步返回结果。
*
* 以下以RSA1024密钥的callback操作使用为例
*/
var
keyalias
=
"
HuksDemoRSA
"
;
var
properties
=
new
Array
();
var
options
=
{
let
keyalias
=
"
HuksDemoRSA
"
;
let
properties
=
new
Array
();
let
options
=
{
properties
:
properties
,
inData
:
new
Uint8Array
(
0
)
};
var
handle
;
var
resultMessage
=
""
;
let
handle
;
let
resultMessage
=
""
;
async
function
generateKey
()
{
properties
[
0
]
=
{
tag
:
huks
.
HuksTag
.
HUKS_TAG_ALGORITHM
,
...
...
@@ -2672,11 +2672,11 @@ async function generateKey() {
huks
.
generateKey
(
keyalias
,
options
);
}
function
stringToUint8Array
(
str
)
{
var
arr
=
[];
for
(
var
i
=
0
,
j
=
str
.
length
;
i
<
j
;
++
i
)
{
let
arr
=
[];
for
(
let
i
=
0
,
j
=
str
.
length
;
i
<
j
;
++
i
)
{
arr
.
push
(
str
.
charCodeAt
(
i
));
}
var
tmpUint8Array
=
new
Uint8Array
(
arr
);
let
tmpUint8Array
=
new
Uint8Array
(
arr
);
return
tmpUint8Array
;
}
async
function
huksInit
()
{
...
...
@@ -2756,20 +2756,20 @@ abort操作密钥接口,使用Promise方式异步返回结果。
*
* 以下以RSA1024密钥的promise操作使用为例
*/
var
keyalias
=
"
HuksDemoRSA
"
;
var
properties
=
new
Array
();
var
options
=
{
let
keyalias
=
"
HuksDemoRSA
"
;
let
properties
=
new
Array
();
let
options
=
{
properties
:
properties
,
inData
:
new
Uint8Array
(
0
)
};
var
handle
;
var
resultMessage
=
""
;
let
handle
;
let
resultMessage
=
""
;
function
stringToUint8Array
(
str
)
{
var
arr
=
[];
for
(
var
i
=
0
,
j
=
str
.
length
;
i
<
j
;
++
i
)
{
let
arr
=
[];
for
(
let
i
=
0
,
j
=
str
.
length
;
i
<
j
;
++
i
)
{
arr
.
push
(
str
.
charCodeAt
(
i
));
}
var
tmpUint8Array
=
new
Uint8Array
(
arr
);
let
tmpUint8Array
=
new
Uint8Array
(
arr
);
return
tmpUint8Array
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录