Advertisement
TizzyT

XOR -TizzyT

Oct 21st, 2018
457
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.58 KB | None | 0 0
  1.         public enum Alignment { Left = 0, Right = 1 }
  2.         public static byte[] Xor(this byte[] arr1, byte[] arr2, Alignment alignment = Alignment.Left)
  3.         {
  4.             if (arr1.Length < arr2.Length) { byte[] ba = arr1; arr1 = arr2; arr2 = ba; }
  5.             byte[] result = new byte[arr1.Length];
  6.             if (alignment == Alignment.Left) Array.Copy(arr2, 0, result, 0, arr2.Length);
  7.             else Array.Copy(arr2, 0, result, arr1.Length - arr2.Length, arr2.Length);
  8.             for (int i = 0; i < arr1.Length; i++) result[i] ^= arr1[i];
  9.             return result;
  10.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement