[JavaScript] avoiding tragedy Password generator

Source: Internet
Author: User

There have been many brute-force databases recently, and password security has become a major issue! How can we avoid simple passwords? Still thinking about passwords? No

I have prepared a password generation tool consisting of 0-9 and a-k English letters. The numbers are in disorder. Replace a random number with a letter to generate a password of 10.

<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <HTML xmlns = "http://www.w3.org/1999/xhtml"> 

How to sort arrays in disorder is a poor math. After searching, input such a function to the array sort.

 
Sort is really powerful.
 
Function unorderedarray (array) {If (({}). tostring. call (array ). indexof ('array') =-1) return; var arr = [], value = array. tostring (); arr = array. sort (function () {return math. random ()> 0.5? -;}); (ARR. tostring () === value) & arguments. callee (array); Return arr ;}

When using this method, we should avoid the generation of arrays, which is the same as the input array. This is a waste of effort, because the array is of a complex type and all modifications will change. Therefore, a variable is used to cache the value of the input array = array. tostring (), and then the value of the array I generated is compared if it is relatively recursive. Ensure that the generated array is not sequential.

 

Use the followingCodeGenerate a random number 0-9

 
Math. Random (). tofixed (1) * 10-1;

 

Use this serial number to get a letter from a-k, and use this letter to replace the numbers at the corresponding position of the serial number in the array.

 

Concatenate the obtained Array Using the join method of the array

 
Password. Join ('');

 

Obtain a key. You are welcome to use it. The blog Park will not post purely code-based posts, so there is so much nonsense. You just need to copy the code and use it directly!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.