SHA256加密-前端 中 HMAC-SHA256的base64加密 和 md5加密

1、 HMAC-SHA256的base64加密

首先

npm install crypto-js --save

项目中使用

1

2

3

4

5

import CryptoJS from 'crypto-js';

 

 

const hash = CryptoJS.HmacSHA256(zhuan, 'secret');//第一个参数为转换的字符串 第二个参数有很多种可能 看需要转换的格式

const hashInBase64 = CryptoJS.enc.Base64.stringify(hash);

 

2、md5加密

首先 

npm install --save js-md5

项目中使用

1

2

3

4

5

import md5 from 'js-md5';

 

//将str字符串进行md5加密

    const str = '111'

    const md5signature = md5(str);

  

1

<em id="__mceDel"> </em>

posted @ 2024-10-10 15:02  Qing`ing  阅读(588)  评论(0)    收藏  举报