SecureTokenGeneratR 1.0.0
See the version list below for details.
dotnet add package SecureTokenGeneratR --version 1.0.0
NuGet\Install-Package SecureTokenGeneratR -Version 1.0.0
<PackageReference Include="SecureTokenGeneratR" Version="1.0.0" />
<PackageVersion Include="SecureTokenGeneratR" Version="1.0.0" />
<PackageReference Include="SecureTokenGeneratR" />
paket add SecureTokenGeneratR --version 1.0.0
#r "nuget: SecureTokenGeneratR, 1.0.0"
#addin nuget:?package=SecureTokenGeneratR&version=1.0.0
#tool nuget:?package=SecureTokenGeneratR&version=1.0.0
Secure Token Generator
Generate random passwords or token; use the default generation rules or set your own.
Using System.Security.Cryptography.RandomNumberGenerator to generate cryptographically strong random values.
- Dependencies: none
- Compatibility: NET Framework 4.6.1+, Net Standard 2.0+
Default Characters Sets
- All numbers
- All lower case latin
- All upper case latin
- Special characters: !"#$%&'()*+,-./:;<=>?@[]^_`{|}~
Default Rules
- Length: 16 characters
- Max repeating characters: 0 (unlimited)
Generator Algorithm
- Populate random positions of the token with at least one random character from each character set.
- Populate all unfilled positions in a random order, each using a random character from a randomly selected characters set.
- Honour the max repeating characters constraint, replace any repeated character exceeding the constraint threshold, each using a random character from a randomly selected characters set.
Installing SecureTokenGeneratR
Install SecureTokenGeneratR with NuGet:
Install-Package SecureTokenGeneratR
Or the .Net Core CLI
dotnet add package SecureTokenGeneratR
Usage
With Default Options
var secureTokenGenerator = new SecureTokenGenerator();
string secureToken = secureTokenGenerator.Generate();
The token generated using the default options will contain 16 characters, with at least one character from each character set (i.e. lower latin, upper latin, number & special character) without limiting the number of occurrence of any character.
Note: while improbable, a random sequence such as 1111111111111111
is not impossible.
With User Defined Options
// Define custom options
var customCharset1 = new CharsetAsSequence("%XW-[]{}"); // Custom characters sets can be provided as string
var customCharset2 = new CharsetAsUnicodeRange(65, 70); // Or as a unicode range, here ABCDEF
var allowedCharsets = new List<ICharacterSet> { customCharset1, customCharset2 };
const int tokenLength = 8;
const int maxRepeatingCharCount = 2; // at most two instances of any characters from all character sets
var secureTokenGenerator = new SecureTokenGenerator(tokenLength, maxRepeatingCharCount, allowedCharsets);
string secureToken = secureTokenGenerator.Generate();
The token generated in the example above will contain 8 characters, at least one character from each characters set and at most two occurrences of any character from all characters sets.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.1
- No dependencies.
-
.NETStandard 2.0
- No dependencies.
-
.NETStandard 2.1
- 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.