Categories > Coding > C++ >

extremely simple password generator in c++

TERIHAX

i say im gay as a joke 🙀

Posts: 2195

Threads: 102

Joined: Jul, 2020

Reputation: 30

Posted

ive been doing random stuff and uh i decided to remake my old shi‍‍tty password generator that was ported from c (again, much simpler)

 

this is extremely simple

 

https://media.discordapp.net/attachments/1108820525230333985/1149059828262645790/image.png

^^ i found this out and thought it was pretty cool

 

#include <iostream>
#include <string>
#include <cstdlib>

int main()
{
    std::srand(time(nullptr));

    std::string characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0987654321~`!@#$%^&*()_+[]\\{}|;':\",/.<>?-=";
    std::string pass;
    
    int length;

    std::cout << "Enter the length of the password:\n";
    std::cin >> length;

    for (int i = 0; i < length; i++)
    {
        pass += characters[std::rand() % characters.length()];
    }

    std::cout << "Generated password:\n" << pass;

    return 0;
}

 

tell me anything i should do better ig

  • 0

Users viewing this thread:

( Members: 0, Guests: 1, Total: 1 )