确保vue项目中有MD5的依赖,当然没有的可以安装crypto模块。

 

npm安装:

npm install --save crypto

 

在main.js文件中将md5引入,可以全局使用的

import crypto from "crypto";
Vue.prototype.$md5 = crypto.createHash("md5");

在需要使用MD5加密的页面中,通过this指向MD5

this.$md5.update(value);

this.$md5.digest("hex")

注:value是你要加密的内容

  this.$md5.digest("hex")的结果就是加密结果

 

相关文章:

  • 2021-11-09
  • 2022-12-23
  • 2022-12-23
  • 2021-10-03
  • 2021-05-04
猜你喜欢
  • 2022-12-23
  • 2022-02-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2019-12-17
相关资源
相似解决方案