RandomCustomStrings 1.0.1

dotnet add package RandomCustomStrings --version 1.0.1
                    
NuGet\Install-Package RandomCustomStrings -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="RandomCustomStrings" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RandomCustomStrings" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="RandomCustomStrings" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add RandomCustomStrings --version 1.0.1
                    
#r "nuget: RandomCustomStrings, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package RandomCustomStrings@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=RandomCustomStrings&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=RandomCustomStrings&version=1.0.1
                    
Install as a Cake Tool

RandomCusomStrings

Ultralight customizable random string generator

Overview

The RandomCustomStrings class in the Promezio.RandomCustomStrings namespace provides a simple yet flexible way to generate random strings in C#. This can be highly useful in scenarios like generating random IDs, passwords, test data, and more. The class allows for extensive customization through the StringConfig class, enabling users to specify the length and character types of the generated strings.

Features

  • Customizable String Length: Define the length of the generated string.
  • Character Type Inclusion: Opt to include uppercase, lowercase, numbers, special characters, and/or custom characters in the string.
  • Custom Character Support: Add any set of custom characters to the string generation pool.

Usage

  1. Add Namespace: Include the namespace in your code.

    using Promezio.RandomCustomStrings;
    
  2. Create Configuration: Instantiate a StringConfig object with your desired settings.

    StringConfig config = new StringConfig(
        lenght: 10, 
        containUppercase: true, 
        containLowercase: true, 
        containNumbers: true, 
        containSpecialChars: true
    );
    
  3. Generate String: Use the Generate method to create a random string.

    string randomString = RandomCustomStrings.Generate(config);
    

Example

StringConfig config = new StringConfig(15, containUppercase: true, containNumbers: true);
string myRandomString = RandomCustomStrings.Generate(config);
Console.WriteLine(myRandomString);

Included seeds

uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
lowercase = "abcdefghijklmnopqrstuvwxyz";
numbers = "0123456789";
specialChars = ",.;:-_*()%$&?!=/";

Use custom characters

 StringConfig config = new StringConfig(10,
         customChars: "@�\|",
         containCustomChars: true);

 string randomString = RandomCustomStrings.Generate(config);

Contribution

Feel free to fork this project, submit pull requests, or report bugs and feature requests on the issue tracker.

License

This project is licensed under the MIT License - see the LICENSE file for details.


Gioele Stefano Luca Fierro

Powered by Promezio

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 319 12/8/2023
1.0.0 215 12/7/2023