HarmonyOS RSA加密,实用字符串转pubKey失败?

如题:HarmonyOS RSA加密,实用字符串转pubKey失败?

阅读 483
1 个回答

报错401为参数密钥的格式问题 需要进行base64转码 请参考以下demo:

let pkData = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0Sgj+kjeK4GQP5nCxHryVNNpPQXEtidEJ1zDfZlrHSKuBpqC6DybMi7hwqQ13WP/E3jmxxx1o3hIlAuAXgNsChutFiRoKpAuQKQY9y4YchvYbDu9zg+vuOaKYinufY1l7p9kDhbozXM9fHKyXju7kZvYDG5T9VATYmQp9CwJTbAXqPz0/o+GJkCkbH1mXUH0kzQHRwXJ68ReqcmlTfe/ThIebSGA/eOvZwa7a3ahCeNJW+8jPfH24WREQ18+gUXIT7T9SU2s6iMpn4Q8yPOG5bdf9qhV1Ws33LVBExCVwoDOZFnJowB3dX3kk8m4LGM6wCA3DoDbtcr+CMWOccTchwIDAQAB";
let skData = new Uint8Array();

let base64 = new util.Base64Helper();
let base64pkData = base64.decodeSync(pkData );
let base64skData = base64.decodeSync(privatekey );
let keyPair = await genKeyPairByData(base64pkData, skData);
let pubKey = keyPair.pubKey;
let priKey = keyPair.priKey;
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
logo
HarmonyOS
子站问答
访问
宣传栏