Skip to content

Commit 36f2b58

Browse files
committed
- removed usage of RNG Crypto Provider and replaced with RandomNumberGenerator
1 parent 077b798 commit 36f2b58

File tree

2 files changed

+20
-21
lines changed

2 files changed

+20
-21
lines changed

PasswordGenerator/Password.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,38 @@ public class Password : IPassword
1717
private const bool DefaultIncludeUppercase = true;
1818
private const bool DefaultIncludeNumeric = true;
1919
private const bool DefaultIncludeSpecial = true;
20-
private static RNGCryptoServiceProvider _rng;
20+
private static RandomNumberGenerator _rng;
2121

2222
public Password()
2323
{
2424
Settings = new PasswordSettings(DefaultIncludeLowercase, DefaultIncludeUppercase,
2525
DefaultIncludeNumeric, DefaultIncludeSpecial, DefaultPasswordLength, DefaultMaxPasswordAttempts,
2626
true);
2727

28-
_rng = new RNGCryptoServiceProvider();
28+
_rng = RandomNumberGenerator.Create();
2929
}
3030

3131
public Password(IPasswordSettings settings)
3232
{
3333
Settings = settings;
3434

35-
_rng = new RNGCryptoServiceProvider();
35+
_rng = RandomNumberGenerator.Create();
3636
}
3737

3838
public Password(int passwordLength)
3939
{
4040
Settings = new PasswordSettings(DefaultIncludeLowercase, DefaultIncludeUppercase,
4141
DefaultIncludeNumeric, DefaultIncludeSpecial, passwordLength, DefaultMaxPasswordAttempts, true);
42-
43-
_rng = new RNGCryptoServiceProvider();
42+
43+
_rng = RandomNumberGenerator.Create();
4444
}
4545

4646
public Password(bool includeLowercase, bool includeUppercase, bool includeNumeric, bool includeSpecial)
4747
{
4848
Settings = new PasswordSettings(includeLowercase, includeUppercase, includeNumeric,
4949
includeSpecial, DefaultPasswordLength, DefaultMaxPasswordAttempts, false);
5050

51-
_rng = new RNGCryptoServiceProvider();
51+
_rng = RandomNumberGenerator.Create();
5252
}
5353

5454
public Password(bool includeLowercase, bool includeUppercase, bool includeNumeric, bool includeSpecial,
@@ -57,7 +57,7 @@ public Password(bool includeLowercase, bool includeUppercase, bool includeNumeri
5757
Settings = new PasswordSettings(includeLowercase, includeUppercase, includeNumeric,
5858
includeSpecial, passwordLength, DefaultMaxPasswordAttempts, false);
5959

60-
_rng = new RNGCryptoServiceProvider();
60+
_rng = RandomNumberGenerator.Create();
6161
}
6262

6363
public Password(bool includeLowercase, bool includeUppercase, bool includeNumeric, bool includeSpecial,
@@ -66,7 +66,7 @@ public Password(bool includeLowercase, bool includeUppercase, bool includeNumeri
6666
Settings = new PasswordSettings(includeLowercase, includeUppercase, includeNumeric,
6767
includeSpecial, passwordLength, maximumAttempts, false);
6868

69-
_rng = new RNGCryptoServiceProvider();
69+
_rng = RandomNumberGenerator.Create();
7070
}
7171

7272
public IPasswordSettings Settings { get; set; }

PasswordGenerator/PasswordGenerator.csproj

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,27 @@
22

33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
5-
<PackageVersion>2.0.2</PackageVersion>
5+
<PackageVersion>2.1.0</PackageVersion>
66
<Title>PasswordGenerator</Title>
77
<Authors>Paul Seal</Authors>
8-
<Description>- Fixed bug with methods that use bool and int parameters for the Password class
8+
<Description>- Removed usage of RNG Crypto Provider and used Random Number Generator
9+
- Fixed bug with methods that use bool and int parameters for the Password class
910
- Removed usage of Random and replace it with a method which uses RngCrytopServiceProvider</Description>
10-
<Copyright>Copyright 2019</Copyright>
11+
<Copyright>Copyright 2022</Copyright>
1112
<PackageProjectUrl>https://github.com/prjseal/PasswordGenerator/</PackageProjectUrl>
12-
<PackageLicenseUrl>https://github.com/prjseal/PasswordGenerator/blob/master/License.md</PackageLicenseUrl>
1313
<PackageIconUrl>https://github.com/prjseal/PasswordGenerator/blob/master/passwordgeneratorlogo.png?raw=true</PackageIconUrl>
1414
<RepositoryUrl>https://github.com/prjseal/PasswordGenerator/</RepositoryUrl>
1515
<RepositoryType>Git</RepositoryType>
16-
<PackageTags>Password,Generator,OWASP,Security,Random,Special,Characters,.net,framework,standard,core,dotnet,dotnetcore,Rng,Crypto,RNGCryptoServiceProvider</PackageTags>
17-
<PackageReleaseNotes>Compatible with .NET Core, .NET Framework and .NET Standard
16+
<PackageTags>Password,Generator,OWASP,Security,Random,Special,Characters,.net,framework,standard,core,dotnet,dotnetcore,Rng,Random,Number,Generator</PackageTags>
17+
<PackageReleaseNotes>Removed usage of RNG Crypto Provider
18+
Compatible with .NET Core, .NET Framework and .NET Standard
1819
Added ability to get a group of passwords in one call</PackageReleaseNotes>
1920
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
20-
<Version>2.0.5</Version>
21-
<AssemblyVersion>2.0.5.0</AssemblyVersion>
22-
<FileVersion>2.0.5.0</FileVersion>
21+
<Version>2.1.0</Version>
22+
<AssemblyVersion>2.1.0.0</AssemblyVersion>
23+
<FileVersion>2.1.0.0</FileVersion>
24+
<RepositoryType>Git</RepositoryType>
25+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
2326
</PropertyGroup>
2427

25-
<ItemGroup>
26-
<PackageReference Include="NuGet.Build" Version="2.12.1" />
27-
</ItemGroup>
28-
2928
</Project>

0 commit comments

Comments
 (0)