Administrator
发布于 2025-03-11 / 7 阅读
0
0

如何获得签名的fingerprint

  • “应用指纹”signatureInfo.fingerprint是应用签名证书(.cer文件)的SHA-256hash值,当前支持获取本应用的“应用指纹”。示例代码如下:

import { bundleManager } from '@kit.AbilityKit'; 
import { hilog } from '@kit.PerformanceAnalysisKit'; 
import { BusinessError } from '@kit.BasicServicesKit'; 
 
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO; 
try { 
  bundleManager.getBundleInfoForSelf(bundleFlags).then((data) => { 
    hilog.info(0x0000, 'testTag', 'getBundleInfoForSelf successfully. Data: %{public}s', JSON.stringify(data)); 
    //data里可以获取到signatureInfo,即应用的签名证书信息 
  }).catch((err: BusinessError) => { 
    hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed. Cause: %{public}s', err.message); 
  }); 
} catch (err) { 
  let message = (err as BusinessError).message; 
  hilog.error(0x0000, 'testTag', 'getBundleInfoForSelf failed: %{public}s', message); 
}


评论