Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6985969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:44:56+00:00 2026-05-27T18:44:56+00:00

I have a password generator that uses the ascii table. I am trying to

  • 0

I have a password generator that uses the ascii table. I am trying to learn how to use the recursion with it. I know there are easy ways to make a generator but I want to learn more about recursion. I want it to choose the letters (65-90) but also choose the numbers (000 – 009)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class PasswordGenerator
{
    static void Main()
    {
        bool bypass = false;
        string errorMessage = "That is an Invalid Number, Please try again";
        string howManyCharacters = "How many Characters would you like the Password to be? (Press '0' to Stop)";
        string pressKeyMessage = "Press any key to continue";
        int length = 0;

        do
        {
            var passwordBuilder = new StringBuilder();
            Console.WriteLine(howManyCharacters);

            var inputIsNumber = int.TryParse(Console.ReadLine(), out length);

            if (!inputIsNumber)
            {
                Console.WriteLine(errorMessage);
                bypass = false;
            }
            else if (inputIsNumber && length != 0)
            {
                for (int i = 0; i < length; i++)
                    passwordBuilder.Append(GetRandomChar());

                Console.WriteLine();
                Console.WriteLine("Password: " + passwordBuilder.ToString());
                Console.WriteLine();
            }
            else
            {
                Console.WriteLine();
                Console.WriteLine(pressKeyMessage);
                Console.ReadLine();
                bypass = true;
            }
        }
        while (!bypass);
    }
    static Random _r = new Random();
    static char GetRandomChar()
    {
        return (char)_r.Next(65, 90); // A through Z
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T18:44:57+00:00Added an answer on May 27, 2026 at 6:44 pm
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    class PasswordGenerator
    {
        static void Main()
        {
            bool bypass = false;
            int length = 0;
    
            do
            {
                var passwordBuilder = new StringBuilder();
                Console.WriteLine("How many Characters would you like the Password to be? (Press '-1' to Stop)");
    
                /// try method is inside, replaced old try and catch
                var Input_is_Int = int.TryParse(Console.ReadLine(), out length);
    
                if (!Input_is_Int || length == 0)
                {
                    Console.WriteLine("That is an Invalid Number, Please try again");
                    Console.WriteLine();
                    bypass = false;
                }
                else if (Input_is_Int && length != -1)
                {
                    for (int i = 0; i < length; i++)
                        passwordBuilder.Append(GetRandomChar());
                    Console.WriteLine("Password: " + passwordBuilder.ToString());
                    Console.WriteLine();
                }
                else
                {
                    Console.WriteLine();
                    Console.WriteLine("Press any key to continue");
                    Console.ReadLine();
                    bypass = true;
                }
            }
            while (!bypass);
        }
    
        /// Union of ABCDEFGHIJKLMNOPQRSTUVWXYZ, 0123456789 and !"#$%&'()*+,-./ 
        static char[] _lookupTable = Enumerable.Range(65, 26).Union(Enumerable.Range(48, 10).Union(Enumerable.Range(33, 14))).Select(i => (char)i).ToArray();
    
        static Random _r = new Random();
    
        static char GetRandomChar()
        {
            var index = _r.Next(0, _lookupTable.Length);
            return _lookupTable[index];
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to figure out an easy way to have a password protected
We have a system that uses password authentication to access a database, the usernames
I have a small web app that uses a simple username/password login scheme. I've
I am making a password generator that generates a random number, then I have
I use bcrypt for password hashing in php 5.3+ I understand that bcrypt uses
I have a powershell script that will generate an email for users whose password
I have a legacy application that uses the ASP.NET membership provider w/ SQL backend.
I have a suite of system tests that uses Spring's JUnit runner, the database
I made a password generator app that works well, but I want to update
I know that variations on this question have been asked, but I've tried all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.