在React中使用crypto-js

问题描述 投票:0回答:1

我使用create-react-app生成了一个应用程序,我想使用crypto-js我收到以下错误

crypto.sha256() is not a function

reactjs create-react-app cryptojs
1个回答
2
投票

你必须使用安装crypto-js

npm install crypto-js

在你的js文件中,你必须导入你想要使用的模块

import sha256 from 'crypto-js/sha256';

现在您可以使用这些功能了

sha256(nonce + message);

在此之前你已经定义了messagenonce

© www.soinside.com 2019 - 2024. All rights reserved.