【遇到问题】前端 MD5 64位 小写 字符串 加密

今天搞了一个 需要MD5 64位加密后才能 请求的 api接口
很头疼搞了好久 在测试过程中总是被加密成32位 ,最后终于找到了64位小写的加密方法

方法:
1. 首先 使用下面命令 下载第三方库 

npm install crypto-js 
 

2. 依次引入"crypto-js/sha256";   和 "crypto-js/enc-hex";

import sha256 from "crypto-js/sha256";

import encHex from "crypto-js/enc-hex";

3. 使用 password  变量 定义被加密的密码,使用 sha256(password) 进行加密

const password = "123456"; // 将要加密的密码
const passwordHash = sha256(password).toString(encHex);
console.log(passwordHash); // 输出 64 位的密码哈希值

4. 下面是打印出来效果
 

8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92


 

猜你喜欢

转载自blog.csdn.net/m0_64494670/article/details/130003046
今日推荐