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

1、 HMAC-SHA256的base64加密

首先

npm install crypto-js --save

项目中使用

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

项目中使用

import md5 from 'js-md5';

//将str字符串进行md5加密
    const str = '111'
    const md5signature = md5(str);

  

 
posted @ 2022-12-08 16:41  Qing`ing  阅读(886)  评论(0编辑  收藏  举报