https://github.com/brix/crypto-js
https://www.npmjs.com/package/crypto-js
crypto文档 https://cryptojs.gitbook.io/docs/
npm install crypto-js
import sha256 from 'crypto-js/sha256';
import hmacSHA512 from 'crypto-js/hmac-sha512';
import Base64 from 'crypto-js/enc-base64';
const message, nonce, path, privateKey; // ...
const hashDigest = sha256(nonce + message);
const hmacDigest = Base64.stringify(hmacSHA512(path + hashDigest, privateKey));
- crypto-js/md5
- crypto-js/sha1
- crypto-js/sha256
- crypto-js/sha224
- crypto-js/sha512
- crypto-js/sha384
- crypto-js/sha3
- crypto-js/ripemd160
密码,基本都是sha256(salt + password)存储在数据库,
每次前端传 password过来,后端那算出来的哈希值和数据库的值进行对比验证