EncryptARCFOUR() public method

public EncryptARCFOUR ( byte data ) : void
data byte
return void
Ejemplo n.º 1
0
 public byte[] Update(byte[] b, int off, int len)
 {
     if (aes)
     {
         if (initiated)
         {
             return(cipher.Update(b, off, len));
         }
         else
         {
             int left = Math.Min(iv.Length - ivptr, len);
             System.Array.Copy(b, off, iv, ivptr, left);
             off   += left;
             len   -= left;
             ivptr += left;
             if (ivptr == iv.Length)
             {
                 cipher    = new AESCipher(false, key, iv);
                 initiated = true;
                 if (len > 0)
                 {
                     return(cipher.Update(b, off, len));
                 }
             }
             return(null);
         }
     }
     else
     {
         byte[] b2 = new byte[len];
         arcfour.EncryptARCFOUR(b, off, len, b2, 0);
         return(b2);
     }
 }
Ejemplo n.º 2
0
 /**
 * Gets a random initialization vector.
 * @param len the length of the initialization vector
 * @return a random initialization vector
 */
 public static byte[] GetIV(int len) {
     byte[] b = new byte[len];
     lock (rc4) {
         rc4.EncryptARCFOUR(b);
     }
     return b;
 }