Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
e6835a40
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看板
未验证
提交
e6835a40
编写于
5月 05, 2022
作者:
O
openharmony_ci
提交者:
Gitee
5月 05, 2022
浏览文件
操作
浏览文件
下载
差异文件
!3630 handle修改
Merge pull request !3630 from shuyi/myfeature
上级
787c165b
8505f521
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
20 addition
and
33 deletion
+20
-33
zh-cn/application-dev/reference/apis/js-apis-huks.md
zh-cn/application-dev/reference/apis/js-apis-huks.md
+20
-33
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-huks.md
浏览文件 @
e6835a40
...
...
@@ -981,13 +981,13 @@ async function routePage() {
console
.
error
(
`fail callback, code:
${
err
.
code
}
, msg:
${
err
.
msg
}
`
)
}
}
var
alias
=
"
HuksDemoRSA
"
;
var
key
alias
=
"
HuksDemoRSA
"
;
var
properties
=
new
Array
();
var
options
=
{
properties
:
properties
,
inData
:
new
Uint8Array
(
0
)
};
var
handle
=
{}
;
var
handle
;
var
resultMessage
=
""
;
async
function
generateKey
()
{
properties
[
0
]
=
{
...
...
@@ -1010,7 +1010,7 @@ async function generateKey() {
tag
:
huks
.
HuksTag
.
HUKS_TAG_DIGEST
,
value
:
huks
.
HuksKeyDigest
.
HUKS_DIGEST_SHA256
};
huks
.
generateKey
(
alias
,
options
);
huks
.
generateKey
(
key
alias
,
options
);
}
function
stringToUint8Array
(
str
)
{
var
arr
=
[];
...
...
@@ -1021,19 +1021,14 @@ function stringToUint8Array(str) {
return
tmpUint8Array
;
}
async
function
huksInit
()
{
await
huks
.
init
(
alias
,
options
).
then
((
data
)
=>
{
await
huks
.
init
(
key
alias
,
options
).
then
((
data
)
=>
{
console
.
log
(
`test init data:
${
JSON
.
stringify
(
data
)}
`
);
handle
=
{
"
handle1
"
:
data
.
handle1
,
"
handle2
"
:
data
.
handle2
};
handle
=
data
.
handle
;
}).
catch
((
err
)
=>
{
console
.
log
(
"
test init err information:
"
+
JSON
.
stringify
(
err
))
})
}
async
function
huksUpdate
()
{
let
count
=
2
;
for
(
let
i
=
0
;
i
<
count
;
i
++
)
{
options
.
inData
=
stringToUint8Array
(
"
huksHmacTest
"
);
await
huks
.
update
(
handle
,
options
).
then
((
data
)
=>
{
if
(
data
.
errorCode
===
0
)
{
...
...
@@ -1041,11 +1036,8 @@ async function huksUpdate() {
}
else
{
resultMessage
+=
"
update fail!
"
;
}
}).
catch
((
err
)
=>
{
resultMessage
+=
"
update times:
"
+
count
+
(
i
+
1
)
+
"
fail catch errorMessage:
"
+
JSON
.
stringify
(
err
)
+
"
"
});
console
.
log
(
resultMessage
);
}
}
function
huksFinish
()
{
options
.
inData
=
stringToUint8Array
(
"
HuksDemoHMAC
"
);
...
...
@@ -1110,7 +1102,7 @@ struct Index {
generateKey
()
})
Button
()
{
Text
(
'
huks
Init
'
)
Text
(
'
Init
'
)
.
fontSize
(
25
)
.
fontWeight
(
FontWeight
.
Bold
)
}.
type
(
ButtonType
.
Capsule
)
...
...
@@ -1124,7 +1116,7 @@ struct Index {
huksInit
()
})
Button
()
{
Text
(
'
huks
Update
'
)
Text
(
'
Update
'
)
.
fontSize
(
25
)
.
fontWeight
(
FontWeight
.
Bold
)
}.
type
(
ButtonType
.
Capsule
)
...
...
@@ -1138,7 +1130,7 @@ struct Index {
huksUpdate
()
})
Button
()
{
Text
(
'
huks
Finish
'
)
Text
(
'
Finish
'
)
.
fontSize
(
25
)
.
fontWeight
(
FontWeight
.
Bold
)
}.
type
(
ButtonType
.
Capsule
)
...
...
@@ -1152,7 +1144,7 @@ struct Index {
huksFinish
()
})
Button
()
{
Text
(
'
huks
Abort
'
)
Text
(
'
Abort
'
)
.
fontSize
(
25
)
.
fontWeight
(
FontWeight
.
Bold
)
}.
type
(
ButtonType
.
Capsule
)
...
...
@@ -1210,13 +1202,13 @@ async function routePage() {
}
}
var
alias
=
"
HuksDemoRSA
"
;
var
key
alias
=
"
HuksDemoRSA
"
;
var
properties
=
new
Array
();
var
options
=
{
properties
:
properties
,
inData
:
new
Uint8Array
(
0
)
};
var
handle
=
{}
;
var
handle
;
var
resultMessage
=
""
;
function
stringToUint8Array
(
str
)
{
var
arr
=
[];
...
...
@@ -1248,17 +1240,14 @@ async function generateKey() {
tag
:
huks
.
HuksTag
.
HUKS_TAG_DIGEST
,
value
:
huks
.
HuksKeyDigest
.
HUKS_DIGEST_SHA256
};
huks
.
generateKey
(
alias
,
options
,
function
(
err
,
data
)
{
});
huks
.
generateKey
(
key
alias
,
options
,
function
(
err
,
data
)
{
});
}
async
function
huksInit
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
huks
.
init
(
alias
,
options
,
async
function
(
err
,
data
)
{
huks
.
init
(
key
alias
,
options
,
async
function
(
err
,
data
)
{
if
(
data
.
errorCode
===
0
)
{
resultMessage
=
"
init success!
"
handle
=
{
"
handle1
"
:
data
.
handle1
,
"
handle2
"
:
data
.
handle2
}
resultMessage
=
"
init success!
"
handle
=
data
.
handle
;
}
else
{
resultMessage
=
"
init fail errorCode:
"
+
data
.
errorCode
}
...
...
@@ -1267,8 +1256,6 @@ async function huksInit() {
}
async
function
huksUpdate
()
{
let
count
=
2
;
for
(
let
i
=
0
;
i
<
count
;
i
++
)
{
options
.
inData
=
stringToUint8Array
(
"
huksHmacTest
"
);
new
Promise
((
resolve
,
reject
)
=>
{
huks
.
update
(
handle
,
options
,
function
(
err
,
data
)
{
...
...
@@ -1280,7 +1267,7 @@ async function huksUpdate() {
});
});
console
.
log
(
resultMessage
);
}
}
async
function
huksFinish
()
{
...
...
@@ -1341,7 +1328,7 @@ struct Index {
generateKey
()
})
Button
()
{
Text
(
'
huks
Init
'
)
Text
(
'
Init
'
)
.
fontSize
(
25
)
.
fontWeight
(
FontWeight
.
Bold
)
}.
type
(
ButtonType
.
Capsule
)
...
...
@@ -1355,7 +1342,7 @@ struct Index {
huksInit
()
})
Button
()
{
Text
(
'
huks
Update
'
)
Text
(
'
Update
'
)
.
fontSize
(
25
)
.
fontWeight
(
FontWeight
.
Bold
)
}.
type
(
ButtonType
.
Capsule
)
...
...
@@ -1369,7 +1356,7 @@ struct Index {
huksUpdate
()
})
Button
()
{
Text
(
'
huks
Finish
'
)
Text
(
'
Finish
'
)
.
fontSize
(
25
)
.
fontWeight
(
FontWeight
.
Bold
)
}.
type
(
ButtonType
.
Capsule
)
...
...
@@ -1383,7 +1370,7 @@ struct Index {
huksFinish
()
})
Button
()
{
Text
(
'
huks
Abort
'
)
Text
(
'
Abort
'
)
.
fontSize
(
25
)
.
fontWeight
(
FontWeight
.
Bold
)
}.
type
(
ButtonType
.
Capsule
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录