CryptoTools.cs 665 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. //
  2. // System.Security.Cryptography.CryptoTools
  3. // Shared class for common cryptographic functionalities
  4. //
  5. // Authors:
  6. // Sebastien Pouliot ([email protected])
  7. //
  8. // Portions (C) 2002 Motus Technologies Inc. (http://www.motus.com)
  9. //
  10. using System;
  11. namespace System.Security.Cryptography {
  12. internal class KeyBuilder {
  13. static private RandomNumberGenerator rng;
  14. static KeyBuilder ()
  15. {
  16. rng = RandomNumberGenerator.Create ();
  17. }
  18. static public byte[] Key (int size)
  19. {
  20. byte[] key = new byte [size];
  21. rng.GetBytes (key);
  22. return key;
  23. }
  24. static public byte[] IV (int size)
  25. {
  26. byte[] iv = new byte [size];
  27. rng.GetBytes (iv);
  28. return iv;
  29. }
  30. }
  31. }