2.8 KiB
Random URL Generator
A simple, cross-platform command-line utility for generating cryptographically secure, random URLs. This project is a C# port of an original Python script, designed to provide unique, non-guessable hostnames for development and testing environments.
Features
- Interactive Menu: Simple menu to select the desired server type.
- Secure by Default: Uses
System.Security.Cryptography.RandomNumberGeneratorfor cryptographically strong randomness, equivalent to Python'ssecretsmodule. - Customizable Prefixes: Easily generates URLs for different services (PostgreSQL, Redis, RabbitMQ, etc.).
- Modern C#: Written using modern C# features like top-level statements and switch expressions for clean, concise code.
- Cross-Platform: Runs anywhere the .NET SDK is installed (Windows, macOS, Linux).
Purpose
In development and cloud environments, there is often a need to create temporary resources with unique hostnames. This tool solves that problem by generating random, hard-to-guess URLs, which helps:
- Prevent Naming Collisions: The random string ensures each generated URL is unique.
- Enhance Security through Obscurity: While not a replacement for proper authentication, a non-guessable hostname makes it harder for unauthorized users to discover or access temporary services.
Prerequisites
To run this project, you will need the .NET 6 SDK or later installed on your system.
How to Run
-
Clone or Download the Code Clone this repository to your local machine or simply download the
Program.csfile.git clone https://github.com/rideaware/url_gen.git cd url_gen -
Run from the Command Line Navigate to the project's root directory in your terminal and use the
dotnet runcommand. The .NET SDK will automatically compile and execute the application.dotnet run -
Follow the Prompts The application will present you with a menu. Enter the number corresponding to your choice and press Enter.
Example Session
Select a server type:
1. PostgreSQL (psql)
2. Redis (redis)
3. RabbitMQ (rabbitmq)
4. Sandbox Web Server (sandbox)
5. Staging Web Server (staging)
Enter a number (1-5) to select a server type, or 'q' to quit: 1
Generated URL: psql-4t9wz1qj.rideaware.org
Generate another URL? (y/n): y
Select a server type:
1. PostgreSQL (psql)
2. Redis (redis)
3. RabbitMQ (rabbitmq)
4. Sandbox Web Server (sandbox)
5. Staging Web Server (staging)
Enter a number (1-5) to select a server type, or 'q' to quit: 4
Generated URL: sandbox-k8m3v7b2.rideaware.org
Generate another URL? (y/n): n
License
This project is licensed under the MIT License. See the LICENSE file for details.