Ejemplo n.º 1
0
 @Before
 public void initValue() {
   try {
     mt = MD5Tool.getInstance();
     md = MessageDigest.getInstance("md5");
     sd = MessageDigest.getInstance("sha1");
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Ejemplo n.º 2
0
 @Test
 public void testDigetStream() {
   try {
     InputStream in = new DigestInputStream(new FileInputStream(loadSelf()), sd);
     int b = -1;
     while ((b = in.read()) != -1) {}
     in.close();
     System.out.println(mt.byteArrayToHexString(sd.digest()));
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Ejemplo n.º 3
0
  @Test
  public void testFile() {

    try {
      StringBuilder builder = new StringBuilder();
      long start = System.currentTimeMillis();
      for (int i = 0; i < 2; i++) {
        builder.append(mt.handleFileInput(loadSelf()));
        builder.append("\n");
      }
      long end = System.currentTimeMillis();
      System.out.printf("Time use:%sms.\n", end - start);
      System.out.printf("md5:\n%s\n", builder.toString());
    } catch (Exception e) {
      e.printStackTrace();
    }
  }