当前位置:网站首页>Password encryption MD5 and salt treatment
Password encryption MD5 and salt treatment
2022-06-28 04:16:00 【weixin_ forty-seven million one hundred and sixty-four thousand】
About password encryption md5 And salt treatment
md5 encryption :
When the user registers, the encrypted password is sent to the back-end storage. When logging in ,
Then match the encrypted password with the encrypted password in the database .
This encryption does not require decryption
One .md5 The in vue In the middle of the day :
1. install .
npm install js-md5 -D
2. Use .
(1) Introduced in the project md5 modular .
import md5 from “js-md5”
(2) stay main.js There will be md5 Convert to vue Prototype
import md5 from "js-md5"
Vue.prototype.$md5=md5
3. Example
<input type="number" v-model="value">
console.log(" Encrypted password :"+ this.$md5(this.value))
Two .md5 The in react In the middle of the day :
First step :
npm install js-md5, Install in the root directory of the file , The instructions are as follows
npm install --save js-md5 // Install into production environment
The second step :
introduce js-md5
At the project entrance file index.js in introduce js-md5
import md5 from 'js-md5'
Mount to react On the prototype of
React.Component.prototype.$md5 = md5
The third step :
To use... In components
import React, {
Component } from 'react'
class friend extends Component {
componentWillMount () {
let str = '123456'
let data = this.$md5(str)
console.log(data) // e10adc3949ba59abbe56e057f20f883e
}
render() {
return (
<div className="friend"> friend friend </div>
)}
}
export default friend
III. salt adding treatment
Directly analyze important data MD5 After processing , Reverse decryption is really difficult , But the flaw can still be found , If the user named LiZicheng can view the database , Then he can observe that his password is the same as that of others , that , Others use the same password as themselves , such , You can log in as someone else . So did our previous encryption methods fail to deal with this behavior ? In fact, just a little confusion can prevent , This is called... In encryption terminology “ Add salt ”. Specifically, in the original material ( User defined password ) Add other ingredients to ( Generally, it is the user's own and constant factor ), In order to increase the system complexity . When this salt is combined with the user password , Then through the summary processing , You can get more hidden summary values . See code below :
// Salt and encrypt the password , Encrypt and then pass Hibernate Save... In the database
String changedPswd = DigestUtils.md5Hex(name + pswd);
It's that simple , Salt in the above code is the user name , If you can, you can also use the email when the user registers , Registration time and other non empty information ( If it's empty, the salting process will fail ). Their actual login passwords are 123456, But you can't see it by looking at user records . Now people with ulterior motives open the database and see completely different passwords , His previous methods have failed .
边栏推荐
- PostgreSQL 实现批量更新、删除、插入
- Digital promising, easy to reach, Huawei accelerates the layout of the commercial market with "five pole" star products
- Meichuang was selected into the list of "2022 CCIA top 50 Chinese network security competitiveness"
- Genicam gentl standard ver1.5 (2)
- Meichuang data security management platform has obtained the evaluation certificate of "data security product capability verification plan" of the Institute
- English grammar_ Adjective / adverb Level 3 - Comparative_ Useful Expressions
- Lingge leangoo agile Kanban tool adds the functions of exporting card documents and pasting shared brain map nodes
- 05 mongodb summary of various column operations
- Learning notes of digital circuit (II)
- Another option for ERP upgrade, MES system
猜你喜欢

第一个.net core MVC项目

简单工厂模式
![[small program practice series] e-commerce platform source code and function implementation](/img/a4/581d73c2ff5c190edc3d8438fa2122.png)
[small program practice series] e-commerce platform source code and function implementation

La norme européenne en 597 - 1 pour les meubles est - elle la même que les deux normes en 597 - 2 pour les ignifuges?

测试/开发程序员真的是青春饭吗?世界是公平的,咱们都凭实力说话......

Reading notes of top performance version 2 (II) -- Performance observation tool

How to write a software test report? Here comes the third party performance report template

Pinda general permission system (day 5~day 6)

With the transformation of automatic empowerment, Feihe dairy accelerates its move towards digitalization!

Introduction notes to machine learning
随机推荐
用一个栈实现另一个栈的排序
在线直播源码,JS动态效果之,侧边栏滚动固定效果
Tiktok actual battle ~ take off the blogger
MySQL master-slave replication, separation and resolution
等保三级密码复杂度是多少?多久更换一次?
Go语言学习教程(十四)
Reading notes of top performance version 2 (II) -- Performance observation tool
After launching the MES system, these changes have taken place in the enterprise
【小程序实战系列】电商平台源码及功能实现
Genicam gentl standard ver1.5 (2)
Lamaba expression learning and common functional interfaces
10:00面试,10:02就出来了 ,问的实在是太...
从零到一,教你搭建「以文搜图」搜索服务(一)
Problems with cat and dog queues
Pinda general permission system (day 5~day 6)
阿里P8倾情推荐,Fiddler抓包工具实战篇(一)
短视频平台开发,点击链接、图片自动跳转到新的页面
05 mongodb summary of various column operations
PostgreSQL implements batch update, deletion and insertion
Supplementary questions of monthly competition