Beispiel #1
0
 public void init(int mode, byte[] key, byte[] iv) throws Exception {
   byte[] tmp;
   if (key.length > bsize) {
     tmp = new byte[bsize];
     System.arraycopy(key, 0, tmp, 0, tmp.length);
     key = tmp;
   }
   try {
     cipher = javax.crypto.Cipher.getInstance("RC4");
     SecretKeySpec _key = new SecretKeySpec(key, "RC4");
     synchronized (javax.crypto.Cipher.class) {
       cipher.init(
           (mode == ENCRYPT_MODE
               ? javax.crypto.Cipher.ENCRYPT_MODE
               : javax.crypto.Cipher.DECRYPT_MODE),
           _key);
     }
     byte[] foo = new byte[1];
     for (int i = 0; i < skip; i++) {
       cipher.update(foo, 0, 1, foo, 0);
     }
   } catch (Exception e) {
     cipher = null;
     throw e;
   }
 }
Beispiel #2
0
  public void init(int mode, byte[] key, byte[] iv) throws Exception {
    String pad = "NoPadding";
    byte[] tmp;
    if (key.length > bsize) {
      tmp = new byte[bsize];
      System.arraycopy(key, 0, tmp, 0, tmp.length);
      key = tmp;
    }

    try {
      cipher = javax.crypto.Cipher.getInstance("RC4");
      SecretKeySpec _key = new SecretKeySpec(key, "RC4");
      cipher.init(
          (mode == ENCRYPT_MODE
              ? javax.crypto.Cipher.ENCRYPT_MODE
              : javax.crypto.Cipher.DECRYPT_MODE),
          _key);
    } catch (Exception e) {
      cipher = null;
      throw e;
    }
  }
Beispiel #3
0
 public void update(byte[] foo, int s1, int len, byte[] bar, int s2) throws Exception {
   cipher.update(foo, s1, len, bar, s2);
 }