Password Gen terminal

Shared by: vectorprobe

cpp

1
#include <iostream>
2
#include <cstdlib>
3
#include <ctime>
4
using namespace std;
5

6
int main()
7
{
8
    srand(time(0));
9
    string password = "";
10
    string characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+{}[];':\"<>,.?/|\\";
11
    int length = 11;
12
    for (int i = 0; i < length; i++)
13
    {
14
        int index = rand() % characters.length();
15
        password += characters[index];
16
    }
17
    cout << "Your random password is: " << password << endl;
18
    return 0;
19
}
20

Love it? Share it!

DevCanvas DevCanvas Logo

Online Editor with a collection of awesome frontend code and code snippets for developers of all levels.

Legal & Support

Stand with Palestine 🇵🇸! DO NOT BE SILENCED

© 2024 DevCanvas. All rights reserved.