mirror of
https://github.com/AlexMacocian/SystemExtensions.git
synced 2026-07-15 14:19:29 +00:00
Merge pull request #8 from AlexMacocian/alexmacocian/extend-cryptorngprovider
Extend CryptoRngProvider api
This commit is contained in:
@@ -35,5 +35,21 @@ namespace SystemExtensions.NetStandard.Security.Tests
|
||||
|
||||
bytes.All(b => b != 0).Should().BeTrue();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetBytes_ShouldReturnBytes()
|
||||
{
|
||||
var bytes = this.cryptoRngProvider.GetBytes(10);
|
||||
|
||||
bytes.Length.Should().Be(10);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetNonZeroBytes_ShouldReturnBytes()
|
||||
{
|
||||
var bytes = this.cryptoRngProvider.GetNonZeroBytes(10);
|
||||
|
||||
bytes.Length.Should().Be(10);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,18 @@ namespace System.Rng
|
||||
{
|
||||
this.rngProvider.GetNonZeroBytes(data);
|
||||
}
|
||||
public byte[] GetBytes(int byteCount)
|
||||
{
|
||||
var bytes = new byte[byteCount];
|
||||
this.GetBytes(bytes);
|
||||
return bytes;
|
||||
}
|
||||
public byte[] GetNonZeroBytes(int byteCount)
|
||||
{
|
||||
var bytes = new byte[byteCount];
|
||||
this.GetNonZeroBytes(bytes);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
private void Dispose(bool disposing)
|
||||
{
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
public interface ICryptoRngProvider
|
||||
{
|
||||
public void GetBytes(byte[] data);
|
||||
public byte[] GetBytes(int byteCount);
|
||||
public void GetNonZeroBytes(byte[] data);
|
||||
public byte[] GetNonZeroBytes(int byteCount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
||||
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
|
||||
<RootNamespace>System</RootNamespace>
|
||||
<Version>1.1.0</Version>
|
||||
<Version>1.1.1</Version>
|
||||
<Authors>Alexandru Macocian</Authors>
|
||||
<RepositoryUrl>https://github.com/AlexMacocian/SystemExtensions</RepositoryUrl>
|
||||
</PropertyGroup>
|
||||
|
||||
Reference in New Issue
Block a user