HarmonyOS 有没有方便读取 .pem key的api,以及相关加密的api

HarmonyOS
2024-12-20 12:54:57
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
fox280

获取pem文件内容

import { util } from '@kit.ArkTS';
import { BusinessError } from '@kit.BasicServicesKit';

@Entry
@Component
struct Index {
  readPemFile() {
    // 读取rawfile目录下的xxx.pem文件
    getContext().resourceManager.getRawFileContent("xxx.pem").then((value: Uint8Array) => {
      let textDecoder: util.TextDecoder = util.TextDecoder.create();
      // 调用util模块的TextDecoder类
      let res: string = textDecoder.decodeWithStream(value);
      // 对Uint8Array解码
      console.log("读取到的内容为:" + res);
    }).catch((error: BusinessError) => {
      console.log("getRawFileContent promise error is " + error);
    });
  }

  build() {
    Column() {
      Button('点击读取文件').onClick(() => {
        this.readPemFile()
      })
    }.justifyContent(FlexAlign.Center).height('100%').width('100%')
  }
}

获取证书内容解析,参考证书算法库框架:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/create-parse-verify-cert-object-V5

加密相关API参考cryptoFramework:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/crypto-architecture-kit-intro-V5

三方库crypto.js: https://gitee.com/openharmony-sig/crypto-js

分享
微博
QQ
微信
回复
2024-12-20 15:33:26
相关问题
HarmonyOS 有没有清除通知相关API
1229浏览 • 1回复 待解决
HarmonyOS 有没有api实现DES加密
823浏览 • 1回复 待解决
有没有获取设备api
1301浏览 • 1回复 待解决
HarmonyOS 有没有图片取色API
1038浏览 • 1回复 待解决
有没有相关api?
5347浏览 • 1回复 待解决
鸿蒙有没有无障碍相关API或者规范呢
10228浏览 • 1回复 已解决
HarmonyOS 有没有单指旋转api
1123浏览 • 1回复 待解决
HarmonyOS 有没有单指旋转api
1285浏览 • 0回复 待解决
有没有获取当前网速api?
5614浏览 • 1回复 待解决
HarmonyOS 视频压缩没有相关api
1558浏览 • 1回复 待解决
HarmonyOS 有没有api可以改应用包名?
1282浏览 • 1回复 待解决
HarmonyOS 读取.properties文件api
832浏览 • 1回复 待解决
Harmony OS有没有类似KeyChainapi提供
1566浏览 • 1回复 待解决