openharmony 鸿蒙 huks-clear-pin-auth-state-arkts

2026-08-25 浏览 (1)

清除PIN码认证状态(ArkTS)

从API版本26.0.0开始,huksExternalCrypto提供清除PIN码认证状态功能接口。应用在密钥操作完成后或需要重置认证状态时,可以调用该接口清除指定资源的PIN码认证状态。具体的场景介绍及规格,请参考Ukey PIN码认证介绍及规格

开发步骤

  1. 获取资源ID。可通过证书选择接口获取keyUri作为resourceId,或通过getResourceId获取外部密钥管理扩展的资源ID。

  2. 调用clearUkeyPinAuthState清除PIN码认证状态。

开发案例

import { huksExternalCrypto } from '@kit.UniversalKeystoreKit';
import { BusinessError } from '@kit.BasicServicesKit';

// 清除PIN码认证状态
async function clearUkeyPinAuthState(resourceId: string): Promise<void> {
  try {
    await huksExternalCrypto.clearUkeyPinAuthState(resourceId)
      .then(() => {
        console.info('promise: clearUkeyPinAuthState success.');
      }).catch((error: BusinessError) => {
        console.error(`promise: clearUkeyPinAuthState failed, errCode : ${error.code}, errMsg : ${error.message}`);
      });
  } catch (error) {
    console.error('promise: clearUkeyPinAuthState input arg invalid.');
  }
}

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 huks-key-import-overview

openharmony 鸿蒙 huks-concepts

openharmony 鸿蒙 huks-signing-signature-verification-arkts

openharmony 鸿蒙 huks-hmac-arkts

openharmony 鸿蒙 huks-key-agreement-overview

openharmony 鸿蒙 huks-as-user-sys

openharmony 鸿蒙 huks-overview

openharmony 鸿蒙 huks-delete-key-ndk

openharmony 鸿蒙 huks-query-authentication-status-arkts

openharmony 鸿蒙 huks-check-key-ndk

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/p0qZgnTb