A simple password generator that generates a password of a given length with numbers, symbols and letters.
- Clone the repository
- Follow our usage guide as below
We provide two use case scenarios for the password generator.
In the first scenario, just copy the all files from the repository and run the main.cpp file. Application will start running on the terminal and will ask for the length and difficulty of the password to be generated. Then, application will generate a password of the given length and difficulty and will print it on the terminal.
In the second scenario, where you may want to implement our password generator in your code directly, you can do it by following the steps below:
- Copy the
PasswordGenerator.hpp
file from the repository. - Include the file in your project.
- Create an object of the class via
PasswordGenerator(length,mode)
constructor. - Call the
generate()
function of the class. - Create an empty string and assign the result of
getPassword()
to it.
PasswordGenerator PG(int length, int difficultyMode)
- This is the constructor of the class. It takes two arguments, length of the password and difficulty mode.
- Length of the password is an integer and difficulty mode is an integer.
- Difficulty mode can be 1, 2 or 3. 1 is for easy, 2 is for medium and 3 is for hard.
- 1 is number based, 2 is numbers and uppercase and lowercase letters and 3 is numbers, uppercase and lowercase letters and symbols.
void generate()
This function generates the password and stores it in the class variable password
. Takes no arguments.
string getPassword()
This function returns the password generated by the generate()
function. Takes no arguments.
An example of the second scenario is given below:
#include "PasswordGenerator.hpp"
#include <iostream>
#include <string>
using namespace std;
int main(){
PasswordGenerator PG(10,1);
PG.generate();
string password = PG.getPassword();
cout << password << endl;
return 0;
}