//************************************** *****************************
// 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 ();
}
<