public static void main(String args[]) {
    try {
      // ReceiveMessageInterface rmiclient;
      RmiServer server = new RmiServer();
      // rmiclient=(ReceiveMessageInterface)(registry.lookup("rmiclient"));
      // rmiclient.generateKeys(publicKey);
      KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
      keyGen.initialize(1024);
      KeyPair keypair = keyGen.genKeyPair();
      publicKey = keypair.getPublic();
      privateKey = keypair.getPrivate();

      BufferedImage image = ImageIO.read(new File("/home/subba/Desktop/test/iris1.bmp"));

      // write it to byte array in-memory (jpg format)
      ByteArrayOutputStream b = new ByteArrayOutputStream();
      ImageIO.write(image, "bmp", b);

      // do whatever with the array...
      byte[] jpgByteArray = b.toByteArray();

      // convert it to a String with 0s and 1s
      StringBuilder sb = new StringBuilder();
      int i = 0;
      for (byte by : jpgByteArray) {
        i++;
        if (i > 366) break;
        sb.append(Integer.toBinaryString(by & 0xFF));
      }
      sb.append("0000000000000000000000000000000000000000000");
      System.out.println(sb.toString().length());
      System.out.println(sb.toString());
      int token = 170;
      StringBuilder sb1 = new StringBuilder();
      sb1.append(Integer.toBinaryString(token));
      for (int j = 0; j < 102; j++) {
        sb1.append("00000000000000000000");
      }
      System.out.println("Binary is " + sb1.length());
      for (i = 0; i < sb.length(); i++) {
        bioTemplate.append(sb.charAt(i) ^ sb1.charAt(i));
      }

      /*MessageDigest digest = MessageDigest.getInstance("SHA-256");
      byte[] hashvalue=serviceProviderKey.getBytes();
      digest.update(hashvalue);
      Phashdigest=digest.digest();
      */

      securePassword = getSecurePassword(serviceProviderKey, "200");
      System.out.println(securePassword);
    } catch (Exception e) {
      e.printStackTrace();
      System.exit(1);
    }
  }
  public String sendDetails(String password, byte[] phash, String transactionID, byte[] spdata)
      throws RemoteException, NotBoundException, NoSuchAlgorithmException, NoSuchPaddingException,
          InvalidKeyException, IllegalBlockSizeException, BadPaddingException {
    Cipher cipher = Cipher.getInstance("RSA");
    cipher.init(Cipher.DECRYPT_MODE, privateKey);
    byte[] cipherData = cipher.doFinal(spdata);
    String x = new String(cipherData);
    String sp[] = new String[10];
    StringTokenizer st = new StringTokenizer(x.toString(), "|");
    int count = 0;
    StringBuilder message = new StringBuilder();
    while (st.hasMoreTokens()) {
      sp[count] = st.nextToken();
      count++;
    }

    String decodemessgae = new String();
    if (securePassword.equals(sp[1]) && serviceProviderId.equals(sp[0].toString().trim())) {
      System.out.println("hellosubba");
      if (transactionID.equals(transactionDetails[0].toString())) {
        int qrData[] = new int[16];

        for (int i = 0; i < password.length(); i++) {
          message.append(password.charAt(i) ^ bioTemplate.charAt(i));
        }
        for (int i = 0; i < message.length(); i++) {
          if (message.charAt(i) == '1') {
            decodemessgae += '0';
          } else decodemessgae += '1';
        }
        int start = 56, end = 63;
        for (int i = 0; i < 16; i++) {
          qrData[i] = Integer.parseInt(decodemessgae.substring(start, end), 2);
          start += 64;
          end += 64;
        }
        RsDecode dec = new RsDecode(16);
        int r = dec.decode(qrData);
        System.out.println("r=" + r);
        System.out.println("qrData=" + java.util.Arrays.toString(qrData));

        int[] MM = new int[qrData.length + 16];
        System.arraycopy(qrData, 0, MM, 0, qrData.length);
        RsEncode enc = new RsEncode(16);
        enc.encode(MM);
        System.out.println("qrData=" + java.util.Arrays.toString(MM));
      }
    } else {
      message.append("unkonw third party user");
    }
    return message.toString();
  }