Skip to content

Commit 825a0b0

Browse files
committed
v1.8.0 - added alternate to RNGCryptoServiceProvider in .NET 6.0 and higher; added tester program for .NET 6.0
1 parent a9195f3 commit 825a0b0

File tree

9 files changed

+314
-40
lines changed

9 files changed

+314
-40
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# RandomString4Net
2-
### Version 1.7.0
2+
### Version 1.8.0
33

44
Author : Lakhya Jyoti Nath (ljnath)<br>
55
Date : September 2020 - December 2022 - January 2023 - October 2023 - November 2023<br>
@@ -42,6 +42,8 @@ etc. etc.
4242
* Added support for .NET (>5.0)
4343
* Added support for .NET Core (>2.2)
4444
* Added support for .NET Standard (>2.0)
45+
* Added support for RandomNumberGenerator in .NET 6.0 and higher as RNGCryptoServiceProvider is marked as obsolete
46+
4547

4648
## Supported Types
4749
* **NUMBER** : *0123456789*

RandomString4Net.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1414
README.md = README.md
1515
EndProjectSection
1616
EndProject
17+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RandomString4NetTesterDotNet", "RandomString4NetTesterDotNet\RandomString4NetTesterDotNet.csproj", "{3F3FA738-BED0-4183-B9B0-32B872B65273}"
18+
EndProject
1719
Global
1820
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1921
Debug|Any CPU = Debug|Any CPU
@@ -32,6 +34,10 @@ Global
3234
{F0A77092-0C76-4151-843C-CD1BD33174B0}.Debug|Any CPU.Build.0 = Debug|Any CPU
3335
{F0A77092-0C76-4151-843C-CD1BD33174B0}.Release|Any CPU.ActiveCfg = Release|Any CPU
3436
{F0A77092-0C76-4151-843C-CD1BD33174B0}.Release|Any CPU.Build.0 = Release|Any CPU
37+
{3F3FA738-BED0-4183-B9B0-32B872B65273}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
38+
{3F3FA738-BED0-4183-B9B0-32B872B65273}.Debug|Any CPU.Build.0 = Debug|Any CPU
39+
{3F3FA738-BED0-4183-B9B0-32B872B65273}.Release|Any CPU.ActiveCfg = Release|Any CPU
40+
{3F3FA738-BED0-4183-B9B0-32B872B65273}.Release|Any CPU.Build.0 = Release|Any CPU
3541
EndGlobalSection
3642
GlobalSection(SolutionProperties) = preSolution
3743
HideSolutionNode = FALSE

RandomString4Net/RandomString.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,16 @@ private static List<string> GetRandomStrings(string[] inputStrings, int count, i
163163
if (count <= 0 || maxLength <= 0)
164164
throw new InvalidLengthException("Number and length of random strings should be a non-zero postive numbver");
165165

166+
byte[] randomSeeds = new byte[1];
167+
168+
#if NET6_0_OR_GREATER
169+
RandomNumberGenerator randomNumberGenerator = RandomNumberGenerator.Create();
170+
randomNumberGenerator.GetBytes(randomSeeds);
171+
#else
166172
// generating a random seed for the Random()
167173
RNGCryptoServiceProvider rngCryptoServiceProvider = new RNGCryptoServiceProvider();
168-
byte[] randomSeeds = new byte[1];
169174
rngCryptoServiceProvider.GetBytes(randomSeeds);
175+
#endif
170176

171177
// creating an instance of Random() using the random seed value
172178
Random random = new Random(randomSeeds[0]);
@@ -198,6 +204,7 @@ private static List<String> getRandomStrings(Random randomInstance, string input
198204

199205
if (forceUnique && randomStrings.Contains(currentRandomString.ToString()))
200206
continue;
207+
201208
randomStrings.Add(currentRandomString.ToString());
202209
}
203210

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFrameworks>net20;net35;net40;net45;net451;net452;net46;net461;net462;net47;net471;net472;net48;netcoreapp2.0;netcoreapp2.1;netcoreapp2.2;netcoreapp3.0;netcoreapp3.1;netstandard2.0;netstandard2.1;net5.0-windows;net6.0-windows;net7.0-windows;net5.0;net6.0;net7.0</TargetFrameworks>
4+
<Version>1.8.0</Version>
5+
<Authors>Lakhya Jyoti Nath</Authors>
6+
<Company>Lakhya's Innovation Inc.</Company>
7+
<Description>.NET library to generate N random strings of M length from various categories</Description>
8+
<Copyright>Copyright © 2020-2023 Lakhya's Innovation Inc.</Copyright>
9+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
10+
<PackageProjectUrl>https://github.com/ljnath/RandomString4Net</PackageProjectUrl>
11+
<RepositoryType>git</RepositoryType>
12+
<RepositoryUrl>https://github.com/ljnath/RandomString4Net.git</RepositoryUrl>
13+
<PackageTags>randomstring4net ljnath lakhya lakhyajyoti innovation lakhya's inc. lakhyajyotinath randomstring random string C# libray password generator passwordgenerator generation symbols randomsymbols lowercase uppercase mixedcase customsymbols randomnumber number</PackageTags>
14+
<PackageReleaseNotes>- Initial release with support for alphabet, alphanumeric with any without symbols for all cases
15+
- Added support for random number generation
16+
- Added support for multiple .NET Framework
17+
- Added support to generate true unique random numbers
18+
- Added performance improvement for .NET Framework &gt; 2.0
19+
- Added support to generate random strings by including strings of each type
20+
- Added support for .NET (&gt;5.0)
21+
- Added support for .NET Core (&gt;2.2)
22+
- Added support for .NET Standard (&gt;2.0)</PackageReleaseNotes>
23+
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
24+
<AssemblyVersion>1.8.0.0</AssemblyVersion>
25+
<FileVersion>1.7.0.0</FileVersion>
26+
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
27+
<AutoGenerateBindingRedirects>False</AutoGenerateBindingRedirects>
28+
<Title>$(AssemblyName)</Title>
29+
<PackageReadmeFile>README.md</PackageReadmeFile>
30+
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
31+
<EnableNETAnalyzers>True</EnableNETAnalyzers>
32+
<SignAssembly>False</SignAssembly>
33+
<AssemblyOriginatorKeyFile>C:\devtools\keys\code_signing_ljnath.pfx</AssemblyOriginatorKeyFile>
34+
<IncludeSymbols>False</IncludeSymbols>
35+
</PropertyGroup>
36+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net20|AnyCPU'">
37+
<DebugType>portable</DebugType>
38+
</PropertyGroup>
39+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net35|AnyCPU'">
40+
<DebugType>portable</DebugType>
41+
</PropertyGroup>
42+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net40|AnyCPU'">
43+
<DebugType>portable</DebugType>
44+
</PropertyGroup>
45+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net45|AnyCPU'">
46+
<DebugType>portable</DebugType>
47+
</PropertyGroup>
48+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net451|AnyCPU'">
49+
<DebugType>portable</DebugType>
50+
</PropertyGroup>
51+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net452|AnyCPU'">
52+
<DebugType>portable</DebugType>
53+
</PropertyGroup>
54+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net46|AnyCPU'">
55+
<DebugType>portable</DebugType>
56+
</PropertyGroup>
57+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net461|AnyCPU'">
58+
<DebugType>portable</DebugType>
59+
</PropertyGroup>
60+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net462|AnyCPU'">
61+
<DebugType>portable</DebugType>
62+
</PropertyGroup>
63+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net47|AnyCPU'">
64+
<DebugType>portable</DebugType>
65+
</PropertyGroup>
66+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net471|AnyCPU'">
67+
<DebugType>portable</DebugType>
68+
</PropertyGroup>
69+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net472|AnyCPU'">
70+
<DebugType>portable</DebugType>
71+
</PropertyGroup>
72+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net48|AnyCPU'">
73+
<DebugType>portable</DebugType>
74+
</PropertyGroup>
75+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netcoreapp3.1|AnyCPU'">
76+
<DebugType>portable</DebugType>
77+
</PropertyGroup>
78+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net20|AnyCPU'">
79+
<DebugType>portable</DebugType>
80+
</PropertyGroup>
81+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net35|AnyCPU'">
82+
<DebugType>portable</DebugType>
83+
</PropertyGroup>
84+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net40|AnyCPU'">
85+
<DebugType>portable</DebugType>
86+
</PropertyGroup>
87+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net45|AnyCPU'">
88+
<DebugType>portable</DebugType>
89+
</PropertyGroup>
90+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net451|AnyCPU'">
91+
<DebugType>portable</DebugType>
92+
</PropertyGroup>
93+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net452|AnyCPU'">
94+
<DebugType>portable</DebugType>
95+
</PropertyGroup>
96+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net46|AnyCPU'">
97+
<DebugType>portable</DebugType>
98+
</PropertyGroup>
99+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net461|AnyCPU'">
100+
<DebugType>portable</DebugType>
101+
</PropertyGroup>
102+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net462|AnyCPU'">
103+
<DebugType>portable</DebugType>
104+
</PropertyGroup>
105+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net47|AnyCPU'">
106+
<DebugType>portable</DebugType>
107+
</PropertyGroup>
108+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net471|AnyCPU'">
109+
<DebugType>portable</DebugType>
110+
</PropertyGroup>
111+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net472|AnyCPU'">
112+
<DebugType>portable</DebugType>
113+
</PropertyGroup>
114+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net48|AnyCPU'">
115+
<DebugType>portable</DebugType>
116+
</PropertyGroup>
117+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netcoreapp3.1|AnyCPU'">
118+
<DebugType>portable</DebugType>
119+
</PropertyGroup>
120+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netcoreapp2.0|AnyCPU'">
121+
<DebugType>portable</DebugType>
122+
</PropertyGroup>
123+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netcoreapp2.1|AnyCPU'">
124+
<DebugType>portable</DebugType>
125+
</PropertyGroup>
126+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netcoreapp2.2|AnyCPU'">
127+
<DebugType>portable</DebugType>
128+
</PropertyGroup>
129+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netcoreapp3.0|AnyCPU'">
130+
<DebugType>portable</DebugType>
131+
</PropertyGroup>
132+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netstandard2.0|AnyCPU'">
133+
<DebugType>portable</DebugType>
134+
</PropertyGroup>
135+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netstandard2.1|AnyCPU'">
136+
<DebugType>portable</DebugType>
137+
</PropertyGroup>
138+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net5.0-windows|AnyCPU'">
139+
<DebugType>portable</DebugType>
140+
</PropertyGroup>
141+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net6.0-windows|AnyCPU'">
142+
<DebugType>portable</DebugType>
143+
</PropertyGroup>
144+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net7.0-windows|AnyCPU'">
145+
<DebugType>portable</DebugType>
146+
</PropertyGroup>
147+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netcoreapp2.0|AnyCPU'">
148+
<DebugType>portable</DebugType>
149+
</PropertyGroup>
150+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netcoreapp2.1|AnyCPU'">
151+
<DebugType>portable</DebugType>
152+
</PropertyGroup>
153+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netcoreapp2.2|AnyCPU'">
154+
<DebugType>portable</DebugType>
155+
</PropertyGroup>
156+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netcoreapp3.0|AnyCPU'">
157+
<DebugType>portable</DebugType>
158+
</PropertyGroup>
159+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netstandard2.0|AnyCPU'">
160+
<DebugType>portable</DebugType>
161+
</PropertyGroup>
162+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netstandard2.1|AnyCPU'">
163+
<DebugType>portable</DebugType>
164+
</PropertyGroup>
165+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net5.0-windows|AnyCPU'">
166+
<DebugType>portable</DebugType>
167+
</PropertyGroup>
168+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net6.0-windows|AnyCPU'">
169+
<DebugType>portable</DebugType>
170+
</PropertyGroup>
171+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net7.0-windows|AnyCPU'">
172+
<DebugType>portable</DebugType>
173+
</PropertyGroup>
174+
<ItemGroup>
175+
<Compile Remove="build\**" />
176+
<EmbeddedResource Remove="build\**" />
177+
<None Remove="build\**" />
178+
</ItemGroup>
179+
<ItemGroup>
180+
<None Include="..\README.md">
181+
<Pack>True</Pack>
182+
<PackagePath>\</PackagePath>
183+
</None>
184+
</ItemGroup>
185+
</Project>

RandomString4Net/RandomString4Net.csproj

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<TargetFrameworks>net20;net35;net40;net45;net451;net452;net46;net461;net462;net47;net471;net472;net48;netcoreapp2.0;netcoreapp2.1;netcoreapp2.2;netcoreapp3.0;netcoreapp3.1;netstandard2.0;netstandard2.1;net5.0-windows;net6.0-windows;net7.0-windows;net5.0;net6.0;net7.0</TargetFrameworks>
4-
<Version>1.7.0</Version>
4+
<Version>1.8.0</Version>
55
<Authors>Lakhya Jyoti Nath</Authors>
66
<Company>Lakhya's Innovation Inc.</Company>
7-
<Description>.NET library to generate N random strings of M length from various categories</Description>
7+
<Description>.NET library to generate N random strings of M length from 13 categories</Description>
88
<Copyright>Copyright © 2020-2023 Lakhya's Innovation Inc.</Copyright>
99
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1010
<PackageProjectUrl>https://github.com/ljnath/RandomString4Net</PackageProjectUrl>
1111
<RepositoryType>git</RepositoryType>
1212
<RepositoryUrl>https://github.com/ljnath/RandomString4Net.git</RepositoryUrl>
13-
<PackageTags>randomstring4net ljnath lakhya lakhyajyoti innovation lakhya's inc. lakhyajyotinath randomstring random string C# libray password generator passwordgenerator generation symbols randomsymbols lowercase uppercase mixedcase customsymbols randomnumber number</PackageTags>
13+
<PackageTags>randomstring4net ljnath lakhya lakhyajyoti innovation lakhya's inc. lakhyajyotinath randomstring random string C# libray password generator passwordgenerator generation symbols randomsymbols lowercase uppercase mixedcase customsymbols randomnumber number </PackageTags>
1414
<PackageReleaseNotes>- Initial release with support for alphabet, alphanumeric with any without symbols for all cases
1515
- Added support for random number generation
1616
- Added support for multiple .NET Framework
@@ -19,10 +19,11 @@
1919
- Added support to generate random strings by including strings of each type
2020
- Added support for .NET (&gt;5.0)
2121
- Added support for .NET Core (&gt;2.2)
22-
- Added support for .NET Standard (&gt;2.0)</PackageReleaseNotes>
22+
- Added support for .NET Standard (&gt;2.0)
23+
- Added support for RandomNumberGenerator in .NET 6.0 and higher as RNGCryptoServiceProvider is marked as obsolete</PackageReleaseNotes>
2324
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
24-
<AssemblyVersion>1.7.0.0</AssemblyVersion>
25-
<FileVersion>1.7.0.0</FileVersion>
25+
<AssemblyVersion>1.8.0.0</AssemblyVersion>
26+
<FileVersion>1.8.0.0</FileVersion>
2627
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
2728
<AutoGenerateBindingRedirects>False</AutoGenerateBindingRedirects>
2829
<Title>$(AssemblyName)</Title>

0 commit comments

Comments
 (0)