做爰高潮a片〈毛片〉,尤物av天堂一区二区在线观看,一本久久A久久精品VR综合,添女人荫蒂全部过程av

最新文章專題視頻專題問答1問答10問答100問答1000問答2000關(guān)鍵字專題1關(guān)鍵字專題50關(guān)鍵字專題500關(guān)鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關(guān)鍵字專題關(guān)鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
當(dāng)前位置: 首頁 - 科技 - 知識百科 - 正文

給nodejs里密碼加密有哪幾種方式

來源:懂視網(wǎng) 責(zé)編:小采 時(shí)間:2020-11-27 19:49:48
文檔

給nodejs里密碼加密有哪幾種方式

給nodejs里密碼加密有哪幾種方式:這次給大家?guī)斫onodejs里密碼加密有哪幾種方式,給nodejs里密碼加密的注意事項(xiàng)有哪些,下面就是實(shí)戰(zhàn)案例,一起來看一下。一、關(guān)于node加密模塊crypto的介紹其實(shí)就是使用MD5加密的,不太安全,在實(shí)際開發(fā)中根據(jù)自己的方案進(jìn)行加鹽處理二、在路由視圖中使用加密
推薦度:
導(dǎo)讀給nodejs里密碼加密有哪幾種方式:這次給大家?guī)斫onodejs里密碼加密有哪幾種方式,給nodejs里密碼加密的注意事項(xiàng)有哪些,下面就是實(shí)戰(zhàn)案例,一起來看一下。一、關(guān)于node加密模塊crypto的介紹其實(shí)就是使用MD5加密的,不太安全,在實(shí)際開發(fā)中根據(jù)自己的方案進(jìn)行加鹽處理二、在路由視圖中使用加密

這次給大家?guī)斫onodejs里密碼加密有哪幾種方式,給nodejs里密碼加密的注意事項(xiàng)有哪些,下面就是實(shí)戰(zhàn)案例,一起來看一下。

一、關(guān)于node加密模塊crypto的介紹

其實(shí)就是使用MD5加密的,不太安全,在實(shí)際開發(fā)中根據(jù)自己的方案進(jìn)行加鹽處理

二、在路由視圖中使用加密方式

1、導(dǎo)入node自帶的加密模塊(不需要安裝)

//導(dǎo)入加密模塊
const crypto = require("crypto");

2、做一個(gè)用戶注冊,密碼加密的視圖

<p class="col-md-6">
 <h4>用戶注冊</h4>
 <form role="form" method="post" action="/regest">
 <p class="form-group">
 <label for="username">用戶名:</label>
 <input id="username" type="text" placeholder="請輸入用戶名" name="username" class="form-control"/>
 </p>
 <p class="form-group">
 <label for="password">密碼:</label>
 <input id="password" type="password" placeholder="請輸入密碼" name="password" class="form-control"/>
 </p>
 <p class="form-group">
 <input type="submit" value="提交" class="btn btn-success"/>
 </p>
 </form>
</p>
router.post("/regest",(req,res)=>{
 console.log(req.body);
 let name = req.body.username;
 let password = req.body.password;
 let md5 = crypto.createHash("md5");
 let newPas = md5.update(password).digest("hex");
 db("insert into user1(name,password) values(?,?)",[name,newPas],(err,data)=>{
 if (err){
 res.send("注冊失敗");
 }
 console.log(data);
 if (data){
 res.send("注冊成功");
 }
 })
});

三、用戶登錄進(jìn)行密碼校驗(yàn)

1、把用戶輸入的密碼用同樣的方式加密處理
2、把加密后的密碼與數(shù)據(jù)庫中匹配

router.post("/login",(req,res)=>{
 let name = req.body.username;
 let password = req.body.password;
 let md5 = crypto.createHash("md5");
 let newPas = md5.update(password).digest("hex");
 db("select * from user1 where name = ?",[name],(err,data)=>{
 console.log(data[0].password);
 if (err){
 res.send("發(fā)生錯(cuò)誤");
 }
 if (data){
 if (data[0].password === newPas){
 res.send("登錄成功");
 }else {
 res.send("用戶名或密碼錯(cuò)誤");
 }
 }
 })
})
<p class="col-md-6">
 <h4>用戶登錄</h4>
 <form role="form" method="post" action="/login">
 <p class="form-group">
 <label for="username2">用戶名:</label>
 <input id="username2" type="text" placeholder="請輸入用戶名" name="username" class="form-control"/>
 </p>
 <p class="form-group">
 <label for="password">密碼:</label>
 <input id="password" type="password" placeholder="請輸入密碼" name="password" class="form-control"/>
 </p>
 <p class="form-group">
 <input type="submit" value="提交" class="btn btn-success" id="sub-btn2"/>
 </p>
 </form>
</p>

四、擴(kuò)展(一般我們加密處理)

1、利用隨機(jī)數(shù)隨機(jī)生成多少位數(shù)
2、利用可逆加密把第一步的生成的隨機(jī)數(shù)加密
可逆加密有Base64Hex加密(具體自己百度)
3、將第二步加密好的隨機(jī)數(shù)與我們真實(shí)密碼拼接在一起
4、將第三步進(jìn)行加密(MD5)
5、將第四步進(jìn)行可逆加密
6、將第二步與第五步生成的拼接成密碼

五、擴(kuò)展(一般我們加密的登錄)

1、登錄時(shí)候獲取密碼
2、從獲取的密碼中截取隨機(jī)數(shù)加密的那段
3、重復(fù)操作上面加密的方式(3,4,5,6)

相信看了本文案例你已經(jīng)掌握了方法,更多精彩請關(guān)注Gxl網(wǎng)其它相關(guān)文章!

推薦閱讀:

vue處理storejs獲取的數(shù)據(jù)

用p5.js制作煙花特效的示例代碼_javascript技巧

聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權(quán)等問題請及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文檔

給nodejs里密碼加密有哪幾種方式

給nodejs里密碼加密有哪幾種方式:這次給大家?guī)斫onodejs里密碼加密有哪幾種方式,給nodejs里密碼加密的注意事項(xiàng)有哪些,下面就是實(shí)戰(zhàn)案例,一起來看一下。一、關(guān)于node加密模塊crypto的介紹其實(shí)就是使用MD5加密的,不太安全,在實(shí)際開發(fā)中根據(jù)自己的方案進(jìn)行加鹽處理二、在路由視圖中使用加密
推薦度:
標(biāo)簽: 密碼 加密 方法
  • 熱門焦點(diǎn)

最新推薦

猜你喜歡

熱門推薦

專題
Top
主站蜘蛛池模板: 韶山市| 蒙城县| 耒阳市| 阳原县| 囊谦县| 吉林市| 祥云县| 苗栗县| 萨嘎县| 通渭县| 罗平县| 自治县| 焉耆| 石台县| 柳河县| 西藏| 乳源| 同仁县| 道孚县| 江油市| 石门县| 修武县| 铁岭县| 平定县| 咸阳市| 长垣县| 安泽县| 碌曲县| 三亚市| 清苑县| 类乌齐县| 仁化县| 金坛市| 泾川县| 奉新县| 平遥县| 潜江市| 淮阳县| 衡东县| 萨嘎县| 中卫市|