npm install crypto-js
import CryptoJS from 'crypto-js';
const plaintext = 'Hello, World!';
function md5Encrypt(message) {
const md5Hash = CryptoJS.MD5(message).toString();
return md5Hash;
}
最后,我们调用 md5Encrypt 函数并将明文消息传递给它:
const md5Hash = md5Encrypt(plaintext);
console.log(md5Hash);