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);
    }
  }
예제 #2
0
파일: Client.java 프로젝트: Eneru/l3s6
  public static void main(String[] args) {
    if (args.length != 1) {
      System.out.println("Usage : java Client <machine du Serveur:port du rmiregistry>");
      System.exit(0);
    }
    try {
      int[][] a = {{1, 0, 0}, {0, 2, 0}, {0, 0, 3}};
      int[][] b = {{1, 2, 3}, {1, 2, 3}, {1, 2, 3}};

      int[][] res;

      OpMatrice op = (OpMatrice) Naming.lookup("rmi://" + args[0] + "/Matrice");
      res = op.multiplicationMatrice(a, b);
      op.AffichageMatrice(res);
    } catch (NotBoundException re) {
      System.out.println(re);
    } catch (RemoteException re) {
      System.out.println(re);
    } catch (MalformedURLException e) {
      System.out.println(e);
    }
  }
 public void crash() {
   System.exit(0);
 }