Vue front-end commonly used encryption processing md5 encryption

md5 encryption:

用户注册时将加密后的密码发送给后端存储
当登陆的时候,再将加密后的密码和数据库中加密的密码相匹配。
此加密无须解密

 

The usage of md5 in vue:

  • 1. Installation.
npm install js-md5 -D

 

  • 2. Use.

(1) The md5 module is introduced into the project.

import md5 from “js-md5”


(2) Convert md5 to vue prototype in main.js

import md5 from "js-md5"
Vue.prototype.$md5=md5

 

  • 3. Example
<input type="number" v-model="value">

console.log("加密密码:"+ this.$md5(this.value))


 

Guess you like

Origin blog.csdn.net/SmartJunTao/article/details/106563092