当前位置:网站首页>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
边栏推荐
- With a younger brother OCR, say no to various types of verification codes!
- Are these old system codes written by pigs?
- TCP BBR as rate based
- DNS domain name system
- Understand what ICMP Protocol is
- An interview question record about where in MySQL
- How to record a database [closed] - how to document a database [closed]
- Period to string [repeat] - period to string [duplicate]
- Zhinai's database
- Detailed explanation of @jsoninclude annotation in Jackson
猜你喜欢

Microsoft issued a document to celebrate Net 20th anniversary!

keil debug查看变量提示not in scope

ACWING/2004. Misspelling

Comparison test of mono 120W high power class D power amplifier chip cs8683-tpa3116
![[200 opencv routines of youcans] 104 Motion blur degradation model](/img/a9/8841ffc8bd3c486bc4011a1a84ff45.jpg)
[200 opencv routines of youcans] 104 Motion blur degradation model

Uncaught TypeError: Cannot read properties of undefined (reading ‘prototype‘)
![[kicad image] download and installation](/img/88/cebf8cc55cb8904c91f9096312859a.jpg)
[kicad image] download and installation
![[core content and derivation] the mystery of human memory system may be just like this](/img/7c/98f27bb55a1a3b74c0ed8fd7fd2cc5.jpg)
[core content and derivation] the mystery of human memory system may be just like this

Laravel8+ wechat applet generates QR code

Sleep quality today 67 points
随机推荐
Understand what ICMP Protocol is
Observation configuring wmic
How to configure log4j to only keep log files for the last seven days?
The "&" character will destroy the data stored in the web The "&" character breaks passwords that are stored in the web config
General test point ideas are summarized and shared, which can be directly used in interview and actual software testing
Global and Chinese benzoic acid market competition strategy and demand scale forecast report 2022
【ROS2】为什么要使用ROS2?《ROS2系统特性介绍》
有能力的人从不抱怨大环境!
Exercise: completion
How to chain multiple different InputStreams into one InputStream
2022 AI trend 8 forecast!
北京网上开股票账户安全吗?
At the age of 26, I was transferred to software testing with zero foundation. Now I have successfully entered the job with a monthly salary of 12K. However, no one understands my bitterness
What is VLAN
Large funds support ecological construction, and Plato farm builds a real meta universe with Dao as its governance
ARM processor operating mode
Derivation of COS (a+b) =cosa*cosb-sina*sinb
Analysis report on global and Chinese pharmaceutical excipients industry competition and marketing model 2022-2028
An interview question record about where in MySQL
Guess the size of the number