title: How can I convert string to bit then split it in half and do some function on a part and then xor it with the other then swap using java?
body: <p>yeah it is simply feistel cipher..
  I need to implement a simple program implementing it without using any preexisting code. 
  I think that my main problem is in conversion of string to bit to do some functions to it? 
  I'm using java by the way,
  and I'm not that expert.
  Please, help me with any info. you think it might help.. </p>
  
  <p>this is my code:</p>
  
  <pre><code>public static String encrypt(String s) {
  // convert to bits
  int sByte = new BigInteger(s.getBytes()).intValue();
  for(int i = 0 ; i&lt;=1 ; i++) {
  
  // split 
  String splitS1 = (""+sByte).substring(0,(""+sByte).length()/2);
  String splitS2 = (""+sByte).substring((""+sByte).length()/2,(""+sByte).length());
  
  // convert to int for function + xor 
  int spl1 = new BigInteger(splitS1.getBytes()).intValue();
  int spl2 = new BigInteger(splitS2.getBytes()).intValue();
  
  int F = 0;
  
  // key based on i 
  if (i == 0) 
  F = spl2 + 0000111; // key 7 
  
  if (i == 1)
  F = spl2 + 00001011; // key 11
  
  // xor
  int xOr = spl1^F;
  
  // swap
  sByte = spl2 + xOr;
  }
  // convert to String
  String AfterEnc = new String(new BigInteger(""+sByte, 2).toByteArray());
  
  return AfterEnc;
  }
  </code></pre>