Example #1
0
  @Test
  public void testDigest() {
    String digest = DigesterUtils.digest("adfs,add,1234.ad", DIGESTER_TYPE.MD5);
    Assert.assertNotNull(digest);
    digest = DigesterUtils.digest("adfs,add,1234.ad", DIGESTER_TYPE.SHA256);
    Assert.assertNotNull(digest);

    byte[] digestb = DigesterUtils.digest("adfs,add,1234.ad".getBytes(), DIGESTER_TYPE.MD5);
    Assert.assertNotNull(digestb);
    digestb = DigesterUtils.digest("adfs,add,1234.ad".getBytes(), DIGESTER_TYPE.SHA256);
    Assert.assertNotNull(digestb);
  }
Example #2
0
  @Test
  public void testMatches() {
    String digest = DigesterUtils.digest(new String("adfs,add,1234.ad"), DIGESTER_TYPE.MD5);
    Assert.assertTrue(DigesterUtils.matches("adfs,add,1234.ad", digest.trim(), DIGESTER_TYPE.MD5));
    digest = DigesterUtils.digest(new String("adfs,add,1234.ad"), DIGESTER_TYPE.SHA256);
    Assert.assertTrue(
        DigesterUtils.matches("adfs,add,1234.ad", digest.trim(), DIGESTER_TYPE.SHA256));

    byte[] digestb = DigesterUtils.digest("adfs,add,1234.ad".getBytes(), DIGESTER_TYPE.MD5);
    Assert.assertTrue(
        DigesterUtils.matches("adfs,add,1234.ad".getBytes(), digestb, DIGESTER_TYPE.MD5));
    digestb = DigesterUtils.digest("adfs,add,1234.ad".getBytes(), DIGESTER_TYPE.SHA256);
    Assert.assertTrue(
        DigesterUtils.matches("adfs,add,1234.ad".getBytes(), digestb, DIGESTER_TYPE.SHA256));
  }