鸿蒙开发:Universal Keystore Kit(密钥管理服务)【获取密钥属性(ArkTS)】

获取密钥属性(ArkTS)

HUKS提供了接口供业务获取指定密钥的相关属性。在获取指定密钥属性前,需要确保已在HUKS中生成或导入持久化存储的密钥。

开发步骤

  1. 指定待查询的密钥别名keyAlias,密钥别名最大长度为64字节。
  2. 调用接口[getKeyItemProperties],传入参数keyAlias和options。 options为预留参数,当前可传入空。
  3. 返回值为[HuksReturnResult]类型对象,获取的属性集在properties字段中。
复制代码
`HarmonyOS与OpenHarmony鸿蒙文档籽料:mau123789是v直接拿`
import { huks } from '@kit.UniversalKeystoreKit';

/* 1. 设置密钥别名 */
let keyAlias = 'keyAlias';
/* option对象传空 */
let emptyOptions: huks.HuksOptions = {
  properties: []
};
try {
  /* 2. 获取密钥属性 */
  huks.getKeyItemProperties(keyAlias, emptyOptions, (error, data) => {
    if (error) {
      console.error(`callback: getKeyItemProperties failed, ` + JSON.stringify(error));
    } else {
      console.info(`callback: getKeyItemProperties success, data = ${JSON.stringify(data)}`);
    }
  });
} catch (error) {
  console.error(`callback: getKeyItemProperties input arg invalid, ` + JSON.stringify(error));
}
相关推荐
小白郭莫搞科技4 小时前
鸿蒙跨端框架Flutter学习:CustomTween自定义Tween详解
学习·flutter·harmonyos
mocoding5 小时前
使用鸿蒙化flutter_fluttertoast替换Flutter原有的SnackBar提示弹窗
flutter·华为·harmonyos
向哆哆6 小时前
构建健康档案管理系统:Flutter × OpenHarmony 跨端实现就医记录展示
flutter·开源·鸿蒙·openharmony·开源鸿蒙
向哆哆8 小时前
画栈 · 跨端画师接稿平台:基于 Flutter × OpenHarmony 的整体设计与数据结构解析
数据结构·flutter·开源·鸿蒙·openharmony·开源鸿蒙
2601_949593658 小时前
高级进阶React Native 鸿蒙跨平台开发:LinearGradient 背景渐变与主题切换
react native·react.js·harmonyos
深海呐8 小时前
鸿蒙基本UI控件(List相关-含Grid)
harmonyos·harmonyos ui·harmonyos list·harmonyos grid·鸿蒙列表view·art列表ui控件·art网格ui控件
小雨青年8 小时前
鸿蒙 HarmonyOS 6 | AI Kit 集成 Core Speech Kit 语音服务
人工智能·华为·harmonyos
一起养小猫10 小时前
Flutter for OpenHarmony 实战 表单处理与验证完整指南
android·开发语言·前端·javascript·flutter·harmonyos
向哆哆10 小时前
构建 Flutter × OpenHarmony 跨端健康档案管理顶部横幅的实现与解析
flutter·开源·鸿蒙·openharmony
向哆哆10 小时前
构建跨端健康档案管理系统:Flutter × OpenHarmony 实战解析
flutter·开源·鸿蒙·openharmony·开源鸿蒙