AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Simple strong password generator11/13/2022 ![]() Srand(delta ^ time ^ pid) // ^ is OK and simple, other better mixing methods exist. Unsigned int pid = (unsigned int) getpid(void) Unsigned int time = (unsigned int) time(NULL) Unsigned int delta = (unsigned int) (clock() - start) #SIMPLE STRONG PASSWORD GENERATOR CODE#Srand((unsigned int)(time(NULL))) is weak, as if one knows the code and about the time used, others can guess the password generated to within a few hundred/thousand combinations. When using passwords, good to scrub buffers: a small step to avoid memory dumps harvesting information. static const char lower_az = "abcdefghijklmnopqrstuvwxyz" Ĭhar lower_letter = lower_az #SIMPLE STRONG PASSWORD GENERATOR PORTABLE#Pedantic: Using this method with letters would make code more portable to more machines as 'a' to 'z' may not be consecutive. static const char punct_set = punct = punct_set To use punctuation, simply select from an array. I want to make it more efficient if I can, and perhaps add some punctuation, which does not seem that easy, since the ASCII codes are quite spread out All you need to do is just put in all the permissible characters in the string and you are bound to get a randomly generated password :) I'd say generating the password is much more advantageous as you can only randomly select from the characters that provide in the string. you can add all the additional punctuations which are required I just added a few punctuations characters for explanatory purpose Int main(void) //int main() is not a valid signature in CĬhar pass //extra byte for null terminating characterĬhar characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/.- =~`:" let me explainĬonsider the following for loop in your code: for (i = 0 i Though you are getting desired output, here in your code you are not exactly generating characters at all indices/positions of the char pass array. Like I said, I want to make it more efficient if I can, and perhaps add some punctuation, which does not seem that easy, since the ASCII codes are quite spread out. I can generate decent passwords, such as: 7Qb4Le2Id0Ss, 1Sw0Nb2Ky1Zp, 0Am3Wa4Wo1Tm and 4Rr4My1Mt1Gj. Printf("Press enter to get a twelve-character password\n") This is my code, I've aimed to make it as simple as possible: #include I've noticed a lot of the password generators people have shown on this are written in Java and maybe Python or C# so hopefully mine will add some variety. It's quite useful for when I'm making a new account and need to make up a quick password on the spot. If the password check failed, you would have to re-generate it.I decided to write a console program that can generate a random alphanumerical password in the C language. You may check if the password meets at least 3 requirements of the “ Password must meet complexity requirements” policy (the password must contain at least 3 types of characters from the following list: numbers, lower-case characters, UPPER-case characters, and special characters). Of course, it does not make sense to check its length and the presence of username in a password. Prior to setting a password to a user, you can make sure that it complies with the password complexity policy. If your company is using a strong password policy, in some cases a password generated with the GeneratePassword method may not meet the requirements of your AD domain password policy. Also, you can use the GeneratePassword method to reset Active Directory user passwords. ![]()
0 Comments
Read More
Leave a Reply. |