我正在尝试从 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();
不会产生预期的结果。
我做的第一个对吗?我该怎么做第二个?