Java Encrypt Byte Array encryptRaw(byte[] key, byte[] b)

Here you can find the source of encryptRaw(byte[] key, byte[] b)

Description

encrypt Raw

License

Open Source License

Declaration

public static byte[] encryptRaw(byte[] key, byte[] b) throws IOException 

Method Source Code


//package com.java2s;
/*/*from   ww w  .java  2  s .c  o m*/
This file is part of Socks via HTTP.
    
This package is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
    
Socks via HTTP is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
    
You should have received a copy of the GNU General Public License
along with Socks via HTTP; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

import java.io.*;

public class Main {
    public static byte[] encryptRaw(byte[] key, byte[] b) throws IOException {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        for (int i = 0; i < b.length; i++) {
            baos.write(b[i] ^ key[i % key.length]);
        }
        return (baos.toByteArray());
    }
}

Related

  1. encrypt(byte[] data, byte[] key)
  2. encryptL(byte[] bytes, int length)