Random Password Generator | C Programming Example
HTML-код
- Опубликовано: 18 сен 2024
- How to create a random password generator in C that generates passwords based on a user specified length incorporating digits, lowercase letters, uppercase letters, and symbols. Source code: github.com/por.... Check out www.portfolioc... to build a portfolio that will impress employers!
Thanks for these videos. You have helped me understand several issues that had previously seemed puzzling. I appreciate it.
How come you can print the value of the pointer ‘password’, without dereferencing the pointer?
So from my understanding we create an character array, we allocate memory to it to store the amount of characters the user wants in their password. (+ 1 to terminate the string)
We run a loop to assign a value of a random character type to the indexes (memory addresses) of the array.
We add ‘\0’ to the password after the loop ends.
Lastly we print the password using a format specifier and the password variable.
So the loop adds the values of random character types to the different memory addresses of the array, but when we print the password, we get values, not memory addresses?
I wish meet you someday 🤩. Thank you for all you do
You’re welcome Olamide! :-)
Thanks. Could you share a tutorial of how the "rand" function is built? The logic behind it that is.
Hmm maybe one day I can do a video on that, that might be neat. :-) Here is something in the meantime: stackoverflow.com/a/4768189.
@Host
Iwas wondering if you can explain the placement of the '*' on the type or the variable name.Does it make a difference? If so what is it?
Example being int*/char* variable_name or int/char *variable_name AND can there be a 'free standing/floating' '*' in between the int/char and var name like int/char * variable_name ?
I actually have a video that goes over these questions you're asking: ruclips.net/video/H5MlTh5cBOg/видео.html. Hopefully that video helps to explain things! :-) You may also find this video interesting as well, it covers a sort of related concept: ruclips.net/video/Qp3WatLL_Hc/видео.html.
@@PortfolioCourses Hello to you and Thank you for getting that link to the video for me. I am going to watch it now.
And thanks for your videos. You definitely do put out a lot of good stuff
@@cleightthejw2202 You're welcome! 🙂
Could have been nice if you included a loop when we enter a short password so the program doesnt close each time
Your explanation for each thing is really great. I just wanted help regarding how can I tell the computer to give me random words from the file which I tell it to read. It would be great help if you could help me out with this. Thanks:)
I'm glad you enjoy the content! :-) That's a great question , but the answer to that is very long I would need to make a whole video I think to try to answer that. If it were me I would read all the content from the file into a string. Then you could count how many words are in the string. Then make a random number between 0 ... total words. You could then output or extract that word from the string by looping through the string again and storing it into a char array. These videos are the closest thing I have right now to what you're asking about:
File Access Basics: ruclips.net/video/HQNsriyMhtY/видео.html
Read All File Contents Into A String: ruclips.net/video/CzAgM5bez-g/видео.html
Count the words in a string: ruclips.net/video/JpquiHExpfI/видео.html
Random number generation: ruclips.net/video/Mp3eGLX-OpY/видео.html
Count the characters and words in a file: ruclips.net/video/H-dehw4nLVM/видео.html
Do you have any videos on unit testing in c?
Unfortunately no, but I do want to cover that topic one day. :-)
Why not use arc4random_uniform? Manual indicates it generates higher quality random numbers. I started in C recently, please don't get me wrong.
Because of learning purpose.
Great question Raphael! :-) arc4random_uniform is an improvement on rand() and would be a great idea! Though it is still pseudo-random. In this video I used rand() because that's what most students looking to learn would be familiar with already from their classes, I think I'll make a separate video on arc4random_uniform() though!
@@PortfolioCourses Thanks for clarifying! I learned these functions a few weeks ago, also to generate random strings. Most information out there teaches to use a rand() family, but it becomes tricky when the documentation itself recommends the arc4random family. Tips on how to judge when to use each of them would be great.
That's a good point, maybe I can address that question in the video itself. It would depend on the quality of the randomness required. Using rand() for learning how to use random numbers as well as harmless things like games should be fine. Something like arc4random_uniform() would be more secure for situations such as this. Though it's possible to do better, the use cases where that's necessary would be more and more niche.
what you program use
In this video I am using Xcode on a Mac. 🙂
good tutorial but you dont actually explain how the code works.
Which part don’t you think is explained? I literally explained the code step by step if you watched the video…
Dont copy this please I will use it in my group project (:
Good luck with your group project. 🙂