【发布时间】:2019-09-21 20:42:53
【问题描述】:
我正在学习 eccrypto - JavaScript 椭圆曲线密码库的基础知识。我从文档中获得了以下代码。
var eccrypto = require("eccrypto");
var privateKeyA = eccrypto.generatePrivate();
var publicKeyA = eccrypto.getPublic(privateKeyA);
// Encrypting the message for A.
eccrypto.encrypt(publicKeyA, Buffer.from("msg to a")).then(function (encrypted) {
console.log(encrypted)
// A decrypting the message.
eccrypto.decrypt(privateKeyA, encrypted).then(function (plaintext) {
console.log("Message to part A:", plaintext.toString());
});
});
恐怕我无法正确理解“加密”对象的密钥。
该对象中有四个键:“iv”、“ephemPublicKey”、 “密文”和“mac”。
如何从该对象中获取二进制格式的加密文本?
【问题讨论】:
-
您将加密文本作为函数的参数,在
.then(...);部分提供。
标签: javascript ecies