Categories > Coding > C# >

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

TERIHAX

i say im gay as a joke ๐Ÿ™€

Posts: 2239

Threads: 102

Joined: Jul, 2020

Reputation: 32

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: 115

Threads: 4

Joined: Apr, 2023

Reputation: 6

Replied

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



Content length must be 10-5000 chars

Comments

TERIHAX 32 Reputation

Commented

"hen brgerb igahopper"?

  • 0

  • 0

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

SeizureSalad

i love femboys

Posts: 1159

Threads: 79

Joined: Mar, 2021

Reputation: 40

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 32 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: 533

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 40 Reputation

Commented

this is almost worse tbh 

  • 0

TERIHAX 32 Reputation

Commented

  • 0

  • 0

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

Senior Dev of Orbit

Discord

Posts: 1430

Threads: 71

Joined: May, 2022

Reputation: 20

Replied

boy what the hell

  • 0

i use arch btw

eb_

Formally known as Shade

vip

Posts: 1045

Threads: 4

Joined: Jun, 2020

Reputation: 47

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 32 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: 8

Threads: 1

Joined: Feb, 2023

Reputation: -2

Replied

hiiiiiiiiiiiiiiiii

 

  • 0

<Hello

Users viewing this thread:

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