Statistics
| Branch: | Revision:

root / trunk / hammock / src / netCF / Hammock.Compact / Mono / Security / Cryptography / KeyBuilder.cs @ 0eea575a

History | View | Annotate | Download (560 Bytes)

1
using System.Security.Cryptography;
2

    
3
namespace Hammock.Mono.Security.Cryptography
4
{
5
  public static class KeyBuilder
6
  {
7
    private static RandomNumberGenerator rng;
8

    
9
    private static RandomNumberGenerator Rng
10
    {
11
      get { return rng ?? (rng = RandomNumberGenerator.Create()); }
12
    }
13

    
14
    public static byte[] Key(int size)
15
    {
16
      var data = new byte[size];
17
      Rng.GetBytes(data);
18
      return data;
19
    }
20

    
21
    public static byte[] IV(int size)
22
    {
23
      var data = new byte[size];
24
      Rng.GetBytes(data);
25
      return data;
26
    }
27
  }
28
}