Home > Web Front-end > JS Tutorial > body text

js random password generation function_javascript skills

WBOY
Release: 2016-05-16 18:21:48
Original
1357 people have browsed it
Copy code The code is as follows:

function randPassword()
{
var text=[ 'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ','1234567890','~!@#$%^&*()_ ";",./?<>'];
var rand = function(min, max ){return Math.floor(Math.max(min, Math.random() * (max 1)));}
var len = rand(8, 16); // The length is 8-16
var pw = '';
for(i=0; i{
var strpos = rand(0, 3);
pw = text[strpos].charAt( rand(0, text[strpos].length));
}
return pw;
}

Test code:

[Ctrl A select all Note: If you need to introduce external Js, you need to refresh to execute
]
Related labels:
js
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template