current position:Home>Front end login password encryption and decryption
Front end login password encryption and decryption
2022-04-29 08:50:04【囍囍囍囍囍囍囍囍囍囍 A】
AES encryption
// Get asymmetric private key
handlePublicKey() {
getPublicKey().then((res) => {
this.publicKey = res;
});
},
// Get symmetric key
handleSymmetricKey() {
getSymmetricKey().then((res) => {
this.loginForm.symmetricKey = res;
});
},
// RSA encryption
encryptRSA(password, pub_key) {
let enc = new JSEncrypt(); // Declare a new JSEncrypt object
enc.setPublicKey(pub_key); // Configure the public key
return enc.encrypt(password); // encryption
},
```// AES encryption
encrypt(word, keyStr) {
// keyStr = keyStr ? keyStr : "absoietlj32fai12";
let key = CryptoJS.enc.Utf8.parse(keyStr);
let srcs = CryptoJS.enc.Utf8.parse(word);
let encrypted = CryptoJS.AES.encrypt(srcs, key, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7,
});
return encrypted.toString();
},
// Decrypt
decrypt(word, keyStr) {
keyStr = keyStr ? keyStr : "absoietlj32fai12";
var key = CryptoJS.enc.Utf8.parse(keyStr);
var decrypt = CryptoJS.AES.decrypt(word, key, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7,
});
return CryptoJS.enc.Utf8.stringify(decrypt).toString();
},
Click login
// RSA encryption
let RSApublicKeyData = this.encryptRSA(
this.loginForm.passwords,
this.publicKey
);
// AES encryption
let AESPassword = this.encrypt(
RSApublicKeyData,
this.loginForm.symmetricKey
);
copyright notice
author[囍囍囍囍囍囍囍囍囍囍 A],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/119/202204290621251449.html
The sidebar is recommended
- How to configure Vue in Vue project config. JS to solve cross domain problems
- Centos6 makes nginx-1.21.6-rpm package -- the way to build a dream
- [vue2-sgg v] vuex
- [vue2-sgg vi] route Vue router guard
- [vue2-sgg VII] Vue export and deploy to nginx --- UI component library (element UI...)
- Chapter 12 Ajax
- Clion remote debugging ubutun server, blood lessons
- The latest vue-i18n international plug-in realizes language switching (with source code)
- Vue monitors watch usage
- Vue encapsulates Axios to the full version of the calling interface (code source code)
guess what you like
Watch data monitoring in Vue and detailed explanation of various attributes in watch
Vue encapsulates Axios to call interface Full Version (code source code) latest recommendation (II)
Vue encapsulates Axios to the full version of the calling interface (code source code)
Ajax usage based on JQ
Vue project optimization
Vue - form generator form code generation
Data acquisition in vuex is assigned to the local problem, and when is vuex data assigned to the local problem
The modal box component is encapsulated in Vue, and the animation effect in Vue
Swiper, the application of swiper in Vue, and various versions of swiper are applied in Vue projects
Python——ReadTimeoutError: HTTPSConnectionPool(host=‘files.pythonhosted.org‘, port=443)
Random recommended
- Lesson 3 of ROS quick start - subscriber subscriber of ROS
- A lifeless face
- Mock in Vue JS preliminary simple use
- The Java Web servlet triggers the alert box on the front end
- CSS sets the color of the small vertical bar in front of the title
- Incomplete display of CSS background image
- [front end learning notes] save the front-end related codes
- Precautions for AWS serverless design dynamodb
- AWS serverless design - apigateway
- AWS serverless design lambda
- AWS serverless design - firewall WAF
- AWS serverless design-s3
- Python repeated element determination function program
- Nginx direction agent solves cross domain Problems-2
- The foundation of JavaScript
- DOM based on JavaScript
- Javascript based BOM
- JavaScript advanced functions
- Basic summary of JavaScript advanced
- Object oriented JavaScript
- JavaScript advanced threading mechanism and event mechanism
- HTML+CSS
- Introduction to less
- CSS3 media query
- Learn about bootstrap
- JQuery learning
- Ajax case
- Ajax sends a post request
- Ajax sends get requests
- Ajax notes
- Ajax learning notes
- Relearn react (1) - recognize the life cycle
- Small problems encountered by react usereducer and Solutions
- CSS realizes the square of adaptive screen width
- Nginx + ModSecurity setup
- Bootstrap web job
- bootstrap
- Swoft 2. X Foundation (HTTP, database, redis)
- Docker actual combat case 2: nginx load balancing
- Vue basic syntax