npm installation:
npm install --save js-md5
1. Introduce in the project files that need to be used:
import md5 from 'js-md5';
use:
md5('hello world') // 5eb63bbbe01eeed093cb22bb8f5acdc3
2. Or convert md5 into vue prototype in the file:
import md5 from 'js-md5'; .$md5 = md5;
use:
this.$md5('hello world') // 5eb63bbbe01eeed093cb22bb8f5acdc3
Vue instance code encrypted using md5
import crypto from 'crypto' export default { name: 'HelloWorld', data () { return { msg: 'Welcome to Your App' } }, mounted(){ this.getmd5("aaa"); }, methods:{ getmd5(str){ var a; var md5 = ("md5"); //update("Chinese", "utf8") (str); var a = ('hex'); (a); //47bce5c74f589f4867dbd57e9ca9f808 return a; } } }
Summarize
The above is the method of using md5 encryption in the vue project introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support for my website!