Advertisement
Guest User

Untitled

a guest
Sep 13th, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. internal interface Cipher
  2. {
  3. void Encrypt(byte[] data, int offset, int len, byte[] result, int result_offset);
  4. void Decrypt(byte[] data, int offset, int len, byte[] result, int result_offset);
  5. int BlockSize { get; }
  6. }
  7.  
  8. public class AES128CTR : Cipher
  9. {
  10. private System.Security.Cryptography.ICryptoTransform Encryptor;
  11. private ArraySegment<Byte> _counter;
  12.  
  13. public AES128CTR(byte[] key, byte[] iv)
  14. {
  15. _counter = new ArraySegment<byte>(iv);
  16. Encryptor = new SecurityDriven.Inferno.Cipher.AesCtrCryptoTransform(key, _counter);
  17. }
  18.  
  19. public int BlockSize { get { return Encryptor.InputBlockSize; } }
  20.  
  21. public void Decrypt(byte[] data, int offset, int len, byte[] result, int result_offset)
  22. {
  23. Encryptor.TransformBlock(data, 0, len, result, 0);
  24. }
  25.  
  26. public void Encrypt(byte[] data, int offset, int len, byte[] result, int result_offset)
  27. {
  28. Encryptor.TransformBlock(data, 0, len, result, 0);
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement