真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

利用javascript如何隨機生成一定位數(shù)的密碼

前言

康保網(wǎng)站制作公司哪家好,找創(chuàng)新互聯(lián)!從網(wǎng)頁設(shè)計、網(wǎng)站建設(shè)、微信開發(fā)、APP開發(fā)、成都響應(yīng)式網(wǎng)站建設(shè)公司等網(wǎng)站項目制作,到程序開發(fā),運營維護。創(chuàng)新互聯(lián)成立與2013年到現(xiàn)在10年的時間,我們擁有了豐富的建站經(jīng)驗和運維經(jīng)驗,來保證我們的工作的順利進行。專注于網(wǎng)站建設(shè)就選創(chuàng)新互聯(lián)

本文主要給大家介紹了關(guān)于利用javascript隨機生成一定位數(shù)密碼的相關(guān)內(nèi)容,分享出來供大家參考學(xué)習(xí),下面話不多少,來一起看看詳細(xì)的介紹吧。

需求

隨機生成一定位數(shù)的密碼,有最小個數(shù)和最大個數(shù),必須包含數(shù)字、大小寫字母,和特殊字符比如(- _ #);

代碼

function createPassword(min,max) {
 //可以生成隨機密碼的相關(guān)數(shù)組
 var num = ["0","1","2","3","4","5","6","7","8","9"];
 var english = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"];
 var ENGLISH = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];
 var special = ["-","_","#"];
 var config = num.concat(english).concat(ENGLISH).concat(special);

 //先放入一個必須存在的
 var arr = [];
 arr.push(getOne(num));
 arr.push(getOne(english));
 arr.push(getOne(ENGLISH));
 arr.push(getOne(special));

 //獲取需要生成的長度
 var len = min + Math.floor(Math.random()*(max-min+1));

 for(var i=4; i

使用

傳入一個生成的密碼的最小位數(shù),和最大位數(shù),即可返回一個隨機密碼

console.log(createPassword(8,15));

總結(jié)

以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作能帶來一定的幫助,如果有疑問大家可以留言交流,謝謝大家對創(chuàng)新互聯(lián)的支持。


本文題目:利用javascript如何隨機生成一定位數(shù)的密碼
URL地址:http://weahome.cn/article/posedi.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部