SHARE
TWEET

Hyperz

a guest May 13th, 2010 202 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. namespace Hyperz.XorCrypt
  4. {
  5.     public sealed class Crypt
  6.     {
  7.         public static unsafe void Xor8(byte[] data, byte key)
  8.         {
  9.             fixed (byte* pData = data)
  10.             {
  11.                 for (int i = 0; i < data.Length; i++) *(pData + i) ^= key;
  12.             }
  13.         }
  14.  
  15.         public static unsafe void Xor32(byte[] data, uint key)
  16.         {
  17.             int i, k;
  18.             byte[] keys = BitConverter.GetBytes(key);
  19.  
  20.             fixed (byte* pData = data)
  21.             {
  22.                 for (k = 0; k < keys.Length; k++)
  23.                     for (i = 0; i < data.Length; i++)
  24.                         *(pData + i) ^= keys[k];
  25.             }
  26.         }
  27.  
  28.         public static unsafe void Xor64(byte[] data, ulong key)
  29.         {
  30.             int i, k;
  31.             byte[] keys = BitConverter.GetBytes(key);
  32.  
  33.             fixed (byte* pData = data)
  34.             {
  35.                 for (k = 0; k < keys.Length; k++)
  36.                     for (i = 0; i < data.Length; i++)
  37.                         *(pData + i) ^= keys[k];
  38.             }
  39.         }
  40.     }
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top