0

我正在尝试使用库 node-jose 将加密的用户对象发送到我的客户端。我真的不明白它是如何工作的。该文档从不谈论如何加密数据对象。

基本上,如何做这样的事情:

app.get("/user", async (req, res) => {
  const user = await User.findById(req.id) // ex: { name: "foo", age: 99 }
  const encryptedUser = User.encryptUser(user) // node-jose acts here
  res.status(200).json({ encryptedUser });
});

然后,在我的 React 应用程序中,我应该能够破译它。谢谢你的帮助!

4

0 回答 0