Code Generator C implementation
# Include
# Include
# Include
// Const char lower_chars [] = "abcdefghijklmnopqrstuvwxyz ";
// Const char upper_chars [] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ ";
// Const char number_chars [] = "0123456789 ";
Const char lower_chars [] = "abcdefghijkmnpqrstuvwxyz"; // no l or o
Const char upper_chars [] = "ABCDEFGHJKLMNPQRSTUVWXYZ"; // no I or O
Const char number_chars [] = "23456789"; // no 1 or 0
Const char special_chars [] = "! @ # $ % ^ & * ()-= _ + [] {};: '\ "<> ,.? /";
Const int _ ks_pass_len = 17;
Void mkpass (char pass [_ ks_pass_len + 1])
{
Int I = 0, j = 0, k = 0, n = 0;
N = _ ks_pass_len/4;
For (; I <n; I ++)
{
Pass [I] = lower_chars [rand () % (strlen (lower_chars)];
Pass [I + n] = upper_chars [rand () % (strlen (upper_chars)];
Pass [I + 2 * n] = number_chars [rand () % (strlen (number_chars)];
Pass [I + 3 * n] = special_chars [rand () % (strlen (special_chars)];
}
J = _ ks_pass_len-4 * n;
For (I = 0; I {
Pass [I + 4 * n] = special_chars [rand () % (strlen (special_chars)];
}
// Disordered characters
For (I = 0; I <32; I ++)
{
J = rand () % (_ ks_pass_len );
K = pass [j];
Pass [j] = pass [I % _ ks_pass_len];
Pass [I % _ ks_pass_len] = k;
}
Pass [_ ks_pass_len] = '\ 0 ';
}
Int _ tmain (int argc, _ TCHAR * argv [])
{
Srand (time (0 ));
Char szPass [_ ks_pass_len + 1];
For (int I = 0; I <16; I ++)
{
Mkpass (szPass );
Printf ("% s \ n", szPass );
}
Return 0;
}