예제 #1
0
 public static void *memcpy(void *src, void *dest, int count)
 {
     if (dest == null || src == null)
     {
         return(null);
     }
     if (dest == src && count <= 0)
     {
         return(dest);
     }
     BufferExtension.BlockCopy((byte *)src, 0, (byte *)dest, count);
     return(dest);
 }
예제 #2
0
파일: RC4.cs 프로젝트: liulilittle/nsjs
 private byte[] CopyBuffer(byte[] value, int ofs, int len)
 {
     if ((ofs + len) > value.Length)
     {
         len = (value.Length - ofs);
     }
     if (ofs < 0 || ofs >= len)
     {
         len = 0;
     }
     byte[] cch = new byte[len];
     BufferExtension.BlockCopy(value, ofs, cch);
     return(cch);
 }
예제 #3
0
파일: RC4.cs 프로젝트: liulilittle/nsjs
        private void Inversion(string key, byte[] sbox, byte *num, int len)
        {
            byte[] vk = new byte[sbox.Length];
            BufferExtension.BlockCopy(sbox, vk, vk.Length);
            for (int i = 0, low = 0, high = 0, mid; i < len; i++)
            {
                low  = (low + key.Length) % MaxbitWidth;
                high = (high + vk[i % MaxbitWidth]) % MaxbitWidth;

                byte b = vk[low];
                vk[low]  = vk[high];
                vk[high] = b;

                mid     = (vk[low] + vk[high]) % MaxbitWidth;
                num[i] ^= (byte)vk[mid];
            }
        }