harmony 鸿蒙Querying Key Aliases

  • 2025-06-12
  • 浏览 (8)

Querying Key Aliases

This topic walks you through on how to query key aliases. >NOTE
> The mini-system devices do not support query of key aliases.

How to Develop

  1. Initialize the key property set.

Set the tag for querying the key aliases. The tag can only be HUKS_TAG_AUTH_STORAGE_LEVEL.

  1. Use listAliases to query the key aliases.
/*
 * The following example uses promise-based APIs to query key aliases.
 */
import { huks } from '@kit.UniversalKeystoreKit'

async function testListAliases() {
  /* 1. Initialize the key property set. */
  let queryProperties: Array<huks.HuksParam> = [
    {
      tag: huks.HuksTag.HUKS_TAG_AUTH_STORAGE_LEVEL,
      value: huks.HuksAuthStorageLevel.HUKS_AUTH_STORAGE_LEVEL_DE
    }
  ];
  let queryOptions: huks.HuksOptions = {
    properties: queryProperties
  };

  try {
    /* 2. Query key aliases. */
    let result: huks.HuksListAliasesReturnResult = await huks.listAliases(queryOptions);
    console.info(`promise: listAliases success`);
  } catch (error) {
    console.error(`promise: listAliases fail`);
  }
}

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Universal Keystore Kit (Key Management Service)

harmony 鸿蒙Specifying the User for Key Operations (for System Applications Only)

harmony 鸿蒙Checking a Key (ArkTS)

harmony 鸿蒙Checking a Key (C/C++)

harmony 鸿蒙Basic Concepts of HUKS

harmony 鸿蒙Deleting a Key (ArkTS)

harmony 鸿蒙Deleting a Key (C/C++)

harmony 鸿蒙Encryption and Decryption (ArkTS)

harmony 鸿蒙Encryption and Decryption (C/C++)

harmony 鸿蒙Encryption and Decryption Overview and Algorithm Specifications

0  赞