[Problems encountered] front-end MD5 64-bit lowercase string encryption

Today, I made an api interface that requires MD5 64-bit encryption to request.
It’s a headache. After a long time, it was always encrypted into 32-bit during the test. Finally, I found a 64-bit lowercase encryption method.

Method:
1. First use the following command to download the third-party library 

npm install crypto-js 
 

2. Import "crypto-js/sha256"; and "crypto-js/enc-hex";

import sha256 from "crypto-js/sha256";

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

3. Use the password variable to define the encrypted password, and use sha256(password) for encryption

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

4. The following is the printed effect
 

8d969eef6ecad3c29a3a629280e686cf0c3f5d5a86aff3ca12020c923adc6c92


 

Guess you like

Origin blog.csdn.net/m0_64494670/article/details/130003046