当前位置:网站首页>Bcrypt password encryption kalrry
Bcrypt password encryption kalrry
2022-06-25 06:38:00 【Python's path to becoming a God】
Bcrypt- Password encryption ---kalrry
One 、 brief introduction
Bcrypt Is a cross platform file encryption tool , The files encrypted by it can be transferred on all supported operating systems and processors . Its password must be 8 to 56 Characters , And will be transformed internally into 448 A key .bcrypt Using Bruce · Schnell is in 1993 Published in Blowfish encryption algorithm . say concretely ,bcrypt Use Paul · Kochel 's algorithm implementation . along with bcrypt The source code released together has slightly changed the original version .
- Bcrypt The algorithm is relatively slow , There is a common saying in the field of cryptography : The slower the algorithm, the safer . The slower the algorithm , The higher the hacking cost .
- adopt salt and cost These two values slow down the encryption process , Encryption time ( hundred ms level ) Far more than md5( Probably 1ms about ) For computers ,Bcrypt The calculation speed of is very slow , But for users , This process is not slow .
- Bcrypt Is one-way , And through salt and cost To deal with , Make it suffer rainbow The probability of attack cracking is greatly reduced , At the same time, the difficulty of cracking is also improved a lot , be relative to MD5 And other encryption methods are more secure , And it's easy to use .
Bcrypt The encrypted string is shaped like :
$2b$10$2UCl0qI6K7tgtFmcO.DzdOKmBxfQorIuUV8Hdb12go7sHJitOV9w.,
// among :
// $ It's a separator , meaningless ;
// 2b yes bcrypt Encryption version number ;
// 10 yes cost Value ;
// Back front 22 Is it salt value ; The next string is the ciphertext of the password ;
Bcrypt Algorithm will salt Random and mix in the final encrypted password , The previous salt, So it doesn't need to be dealt with separately salt problem .
Two 、 Use
1. install
npm i bcrypt --save
2. Encryption code
//1、 Introduce modules
let bcrypt= require("bcrypt");
//2、 produce salt
let salt = bcrypt.genSaltSync(11); // 11 Is the number of iterations
//3、 encryption
// bcrypt.hashSync( The password entered when the user registers ,salt);
let pass = bcrypt.hashSync("123456",salt);
console.log("pass",pass);//pass Is the result of encryption , This can be stored in the database
// $2b$10$1MtFAztjfpDTm8z.PjQTwOo6k4FrRiXwbZKq0oAKWqWI94mhzJfTG
// $2b$11$jMC6xi32MVFDApY.valjJ.f7W5gGXQoLj3VZlrPQ8Fik.pVQ/szTK
3. contrast
Check whether the password entered by the user is consistent with that in the database
// Verify that the password is correct
//1、 Introduce modules
let bcrypt= require("bcrypt");
// let isMatch = bcrypt.compareSync( The password entered when the user logs in , The password from the database );
let isMatch = bcrypt.compareSync("123456","$2b$11$jMC6xi32MVFDApY.valjJ.f7W5gGXQoLj3VZlrPQ8Fik.pVQ/szTK");
console.log(isMatch);//true: Indicates that the password is consistent ;false: Password inconsistency
Reference resources
边栏推荐
- Kotlin reflection -- Notes
- BGP - basic concept
- Ht513 I2S input 2.8W mono class D audio power amplifier IC
- 'how do I create an enumeration with constant values in rust?'- How can I create enums with constant values in Rust?
- Viewing Chinese science and technology from the Winter Olympics (V): the Internet of things
- ASP. Net core - encrypted configuration in asp NET Core
- Methods for obtaining some information of equipment
- DataX tutorial (09) - how does dataX achieve speed limit?
- HCIP Day 16
- Analysis report on demand scale and Supply Prospect of global and Chinese thermal insulation materials market during the 14th Five Year Plan period 2022-2028
猜你喜欢

We cannot activate inspection type for article master in transaction code MM41?

JS dynamic table creation
![[short time average zero crossing rate] short time average zero crossing rate of speech signal based on MATLAB [including Matlab source code 1721]](/img/4a/304f262c1c08800aa95f9e2d537e4d.jpg)
[short time average zero crossing rate] short time average zero crossing rate of speech signal based on MATLAB [including Matlab source code 1721]

ACWING/2004. Misspelling

Asemi fast recovery diode us1m parameters, us1m recovery time, us1m voltage drop

DNS domain name system

Cve-2022-23131 - bypass SAML SSO authentication
![[200 opencv routines of youcans] 104 Motion blur degradation model](/img/a9/8841ffc8bd3c486bc4011a1a84ff45.jpg)
[200 opencv routines of youcans] 104 Motion blur degradation model

After five years of software testing in ByteDance, I was dismissed in December to remind my brother of paddling

Exercise: completion
随机推荐
Zero foundation wants to learn web security, how to get started?
Talk about TCP and UDP
With a younger brother OCR, say no to various types of verification codes!
[speech discrimination] discrimination of speech signals based on MATLAB double threshold method [including Matlab source code 1720]
Analysis report on investment and financing status and operation benefits of global and Chinese dental industry (2022 Edition)
アルマ / 炼金妹
Your local changes to the following files would be overwritten by merge: .vs/slnx.sqlite
Laravel8+ wechat applet generates QR code
How do I check swift if two arrays contain the same elements, regardless of the order in which they appear?
Cve-2022-23131 - bypass SAML SSO authentication
Navicat防止新建查询误删
Explain @builder usage
Global and China chemical mechanical polishing abrasive materials market demand outlook and investment scale forecast report 2022 Edition
China rehabilitation hospital industry operation benefit analysis and operation situation investigation report 2022
Cannot activate inspection type when SAP retail uses transaction code mm41 to create commodity master data?
Asemi fast recovery diode us1m parameters, us1m recovery time, us1m voltage drop
The "&" character will destroy the data stored in the web The "&" character breaks passwords that are stored in the web config
sin(a-b)=sina*cosb-sinb*cosa的推导过程
ASP. Net core - Safety of asynclocal in asp NET Core
Advantages and disadvantages of using SNMP and WMI polling