title: Implementation of A5/1 algorithm in java is not giving any output
body: <p>Following code is not giving any decrypted output</p>
  
  <hr>
  
  <p>Sample:</p>
  
  <p>Enter the string to be encrypted:<br>
  hello                                                                                                                                                                                                 </p>
  
  <p>Enter the 64 bit key<br>
  0000000000111111111100000000001111111111000000000011111111110101                                                                                                                                                                          </p>
  
  <p>The encrypted message is:<br>
  00101110100000001001010111001101101                                                                                                                                                                   </p>
  
  <p>The decrypted message is:  </p>
  
  <hr>
  
  <p>Can anyone tell what is wrong with the code?</p>
  
  <pre><code>    import java.io.*;
  
      class A51 {
  
          public static void main(String args[])throws Exception {
  
              BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
  
              System.out.println("Enter the string to be encrypted:");
              String msg = br.readLine();
  
              byte[] st = null;
              st = msg.getBytes("UTF-8");
  
              msg = "";
  
              for(byte b:st) {
                  msg = msg + Integer.toBinaryString(b);
              }
  
              int len = msg.length();
              int s[] = new int[len];
  
              System.out.println("\nEnter the 64 bit key");
  
              int x[] = new int[19];
              int y[] = new int[22];
              int z[] = new int[23];
              int i;
  
              String str[] = br.readLine().split("");
  
              for(i=0; i&lt;19; i++)
                  x[i] = Integer.parseInt(str[i]);
  
              for(i=0; i&lt;22; i++)
                  y[i] = Integer.parseInt(str[i+19]);
  
              for(i=0; i&lt;23; i++)
                  z[i] = Integer.parseInt(str[i+19+22]);
  
              int m = 0, t;
  
              for(int j=0; j&lt;len; j++) {
  
                  if(x[8]==y[10] || x[8]==z[10])
                      m = x[8];
                  else if(y[10]==z[10])
                      m = y[10];
  
                  if(x[8]==m) {
                      t = x[13]^x[16]^x[17]^x[18];
                      for(i=18; i&gt;0; i--)
                          x[i] = x[i-1];
                      x[0] = t;
                  }
  
                  if(y[10]==m) {
                      t = y[20]^y[21];
                      for(i=21; i&gt;0; i--)
                          y[i] = y[i-1];
                      y[0] = t;
                  }
  
                  if(z[10]==m) {
                      t = z[7]^z[20]^z[21]^z[22];
                      for(i=22; i&gt;0; i--)
                          z[i] = z[i-1];
                      z[0] = t;
                  }
  
                  s[j] = x[18]^y[21]^z[22];  
              }
  
              int enc[] = new int[len];
              int dec[] = new int[len];
  
              System.out.println("\nThe encrypted message is:");
              for(i=0; i&lt;len; i++) {
                  enc[i] = Integer.parseInt(Character.toString(msg.charAt(i)))^s[i];
                  System.out.print(enc[i]);
              }
  
              msg = "";
  
              System.out.println("\n\nThe decrypted message is:");
              for(i=0; i&lt;len; i++) {
                  msg = msg + dec[i];
                  if(i%7==6) {
                      int decp = Integer.parseInt(msg, 2);
                      System.out.print((char)decp);
                      msg = "";
                  }
              }
          }
      }
  </code></pre>