public static byte [ ] encrypt ( byte [ ] data , byte [ ] key ) { checkNotNull ( data ) ; checkNotNull ( key ) ; checkArgument ( key . length >= 5 && key . length <= 256 ) ; StreamCipher rc4 = new RC4Engine ( ) ; rc4 . init ( true , new KeyParameter ( key ) ) ; byte [ ] encrypted = new byte [ data . length ] ; rc4 . processBytes ( data , 0 , data . length , encrypted , 0 ) ; return encrypted ; }
Encrypt data bytes using RC4