Categories > Coding > C# >

[Rel] Useless Password Generator | Requested by @Astronemi for Random Project Ideas

TERIHAX

i say im gay as a joke ๐Ÿ™€

Posts: 2195

Threads: 102

Joined: Jul, 2020

Reputation: 30

Posted

using System;
using System.Linq;

class PasswordGenerator
{
    private static readonly string characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()-_=+";

    static void Main()
    {
        Console.Write("Enter the desired length of the password: ");
        int length = int.Parse(Console.ReadLine());

        Console.WriteLine("Generated password:\r\n{GeneratePassword(length)}");
    }

    public static string GeneratePassword(int length) => new string(Enumerable.Repeat(characters, length).Select(s => s[new Random().Next(s.Length)]).ToArray());
}

 

OK SO @reversed_coffee wants me to use rngcryptoserviceprovider, so heres it, I HAVE REALLY SH*TTY CODE IM SORRY

using System;
using System.Security.Cryptography;
using System.Text;

class PasswordGenerator
{
    private static readonly string characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()-_=+";

    static void Main()
    {
        Console.Write("Enter the desired length of the password: ");
        int length = int.Parse(Console.ReadLine());

        Console.WriteLine($"Generated password: {GeneratePassword(length)}");
    }

    public static string GeneratePassword(int length)
    {
        using (RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider())
        {
            byte[] data = new byte[length];
            rng.GetBytes(data);

            StringBuilder passwordBuilder = new StringBuilder(length);
            foreach (byte b in data)
            {
                passwordBuilder.Append(characters[b % characters.Length]);
            }

            return passwordBuilder.ToString();
        }
    }
}

 

IM SO SORRY FOR MY SH*TTY CODE

 

easy asl

 

suggested by @Astronemi from https://forum.wearedevs.net/t/33780 for random project ideas to do bc i was bored

  • 0

Posts: 111

Threads: 4

Joined: Apr, 2023

Reputation: 6

Replied

แ‚ฌเดฒ๐Ÿ† แ’ƒ๐œžแ€Œเดฒ๐œžแ’ƒ่ฎ แ€Œ แƒจ แ‚ฌโŠ•๐“น๐“นเดฒ๐œž



Content length must be 10-5000 chars

Comments

TERIHAX 30 Reputation

Commented

"hen brgerb igahopper"?

  • 0

  • 0

"your code looks like a decompiled roblox script", - Whoman

SeizureSalad

i love femboys

Posts: 1153

Threads: 79

Joined: Mar, 2021

Reputation: 36

Replied

what the HELL is that code it ain't "clean" or anything that's literally unreadable lmao

 

"haha one line == better!!!! because less lines!!!"

Comments

TERIHAX 30 Reputation

Commented

thats how i like to do it, i like ti keep everything extremely minimal

  • 0

  • 0

"Questionable intellegence, but I like the mystery" - CubeFaces

https://cdn.discordapp.com/attachments/1136067487847415848/1138948596679589898/sig.png

Posts: 522

Threads: 41

Joined: May, 2020

Reputation: 4

Replied

The code but readable 

using System;
using System.Linq;

class PasswordGenerator
{
    private static readonly string characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()-_=+";

    static void Main()
    {
        Console.Write("Enter the desired length of the password: ");
        int length = int.Parse(Console.ReadLine());

        string password = GeneratePassword(length);
        Console.WriteLine("Generated password:\r\n" + password);
    }

    public static string GeneratePassword(int length)
    {
        Random random = new Random();
        char[] passwordChars = new char[length];

        for (int i = 0; i < length; i++)
        {
            int index = random.Next(characters.Length);
            passwordChars[i] = characters[index];
        }

        return new string(passwordChars);
    }
}

Comments

SeizureSalad 36 Reputation

Commented

this is almost worse tbh 

  • 0

TERIHAX 30 Reputation

Commented

  • 0

  • 0

nltr | Xaml & C# Developer Former Fluxus Administrator
------------------------------------------------------------------------------------
๐Ÿ’œ Developer of Kronos ๐Ÿ’œ

Senior Dev of Orbit

Discord

Posts: 1391

Threads: 71

Joined: May, 2022

Reputation: 17

Replied

boy what the hell

  • 0

Did I mention I use arch btw?

eb_

Formally known as Shade

vip

Posts: 1044

Threads: 4

Joined: Jun, 2020

Reputation: 44

Replied

i dont get it with ppl making password gens like theres no use unless ur intereted and actively developing for example a softwore that encytps your passwords or saves those random gen passwords or smth like kaspersky

Comments

TERIHAX 30 Reputation

Commented

only reason i did it was because i got bored and asked for things to make and i got suggested to make a pass gen

  • 0

  • 0

https://media.discordapp.net/attachments/1010636204225601659/1012865624797610044/sKQybOLT.gif

Posts: 6

Threads: 1

Joined: Feb, 2023

Reputation: -2

Replied

hiiiiiiiiiiiiiiiii

 

  • 0

<Hello

Users viewing this thread:

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