Skip to content

Commit

Permalink
Remove Helpers.GenerateRandom
Browse files Browse the repository at this point in the history
It is identical to `RandomNumberGenerator.GetBytes`.
  • Loading branch information
teo-tsirpanis committed Apr 30, 2022
1 parent e938e44 commit a889557
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ public void SetKeySize(int keySize, ICngSymmetricAlgorithm outer)

public void GenerateKey()
{
byte[] key = Helpers.GenerateRandom(AsymmetricAlgorithmHelpers.BitsToBytes(_outer.BaseKeySize));
byte[] key = RandomNumberGenerator.GetBytes(AsymmetricAlgorithmHelpers.BitsToBytes(_outer.BaseKeySize));
SetKey(key);
}

public void GenerateIV()
{
byte[] iv = Helpers.GenerateRandom(AsymmetricAlgorithmHelpers.BitsToBytes(_outer.BlockSize));
byte[] iv = RandomNumberGenerator.GetBytes(AsymmetricAlgorithmHelpers.BitsToBytes(_outer.BlockSize));
_outer.IV = iv;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,6 @@ public static byte[] FixupKeyParity(this byte[] key)
return oddParityKey;
}

internal static byte[] GenerateRandom(int count)
{
byte[] buffer = new byte[count];
RandomNumberGenerator.Fill(buffer);
return buffer;
}

// Encode a byte array as an array of upper-case hex characters.
internal static char[] ToHexArrayUpper(this byte[] bytes)
{
Expand Down

0 comments on commit a889557

Please sign in to comment.