【发布时间】:2021-05-31 08:33:07
【问题描述】:
我正在尝试从 AWS KMS 调用(Node.js SDK)的返回值中获取字符串数据:
const pair = await kms.generateDataKeyPairWithoutPlaintext(params);
它返回 pair.PrivateKeyCiphertextBlob 和 pair.PublicKey 作为 Uint8Array blob。我需要先制作一个 base64 字符串,然后再制作一个纯文本。
我。 想想我得到了第一个:
const buff = Buffer.from(pair.PrivateKeyCiphertextBlob);
const privateKey = buff.toString('base64');
(虽然我不确定)而且我真的很难从第二个中提取纯文本。类似的东西
const publicKey = Buffer.from(pair.PublicKey).toString();
不会产生预期的结果。
我做的第一个对吗?第二个怎么办?
【问题讨论】:
标签: javascript node.js amazon-web-services key-pair amazon-kms