Brute force password algorithm

Source: Internet
Author: User


//************************************** *****************************
// In many cases, we need to use combinations of algorithms, such as the cryptographic dictionary.
// The Key to this algorithm is the subscript carry of the password.
// In addition, the efficiency of writing a file statement in this example is relatively low, and it is not optimized to reduce the algorithm complexity.
// To improve the efficiency of file writing, you can use a buffer to write data in batches.
//************************************** * ****** Breath.cnpick.com *****

Void createpassword ()
{
# Define passwordmax 8 // Maximum length of the generated Password

Char a [] = "0123456789 abcdefghijklmnopqrstuvwxyz"; // possible characters
Long ndictcount = sizeof (a); // obtain the dictionary length of the password.
Char cpass [passwordmax + 2]; // The generated Password
Long nminl = 1, nmaxl = 3; // In this example, the password length ranges from 1 to 3.
Long array [passwordmax]; // password dictionary subscript

Assert (nminl <= nmaxl & nmaxl <= passwordmax); // Fault Tolerance guarantee
Long nlength = nminl;
Register long j, I = 0;
Bool bnext;
Cstdiofile file;
File. open ("c: \ dict.txt", cfile: modecreate | cfile: modewrite );
While (nlength <= nmaxl)
{
For (I = 0; I <passwordmax; I ++)
Array [I] = 0;
Bnext = true;
While (bnext)
{
For (I = 0; I <nlength; I ++)
Cpass [I] = a [array [I>;
Cpass [I] = '';
File. writestring (cpass );
File. writestring ("n ");
For (j = nlength-1; j> = 0; j --) // password pointer carry
{
Array [j] ++;
If (array [j]! = Ndictcount-1) break;
Else
{
Array [j] = 0;
If (j = 0) bnext = false;
}
}

}
Nlength ++;
}
File. close ();
}


<

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.