Package gnu.java.security.hash

Examples of gnu.java.security.hash.Whirlpool


  public void test(TestHarness harness)
  {
    harness.checkPoint("TestOfWhirlpool");
    try
      {
        algorithm = new Whirlpool();
        harness.check(algorithm.selfTest(), "selfTest");
      }
    catch (Exception x)
      {
        harness.debug(x);
        harness.fail("TestOfWhirlpool.selfTest");
      }

    try
      {
        algorithm = new Whirlpool();
        algorithm.update("a".getBytes(), 0, 1);
        byte[] md = algorithm.digest();
        harness.check(TV1.equals(Util.toString(md)), "testA");
      }
    catch (Exception x)
      {
        harness.debug(x);
        harness.fail("TestOfWhirlpool.testA");
      }

    try
      {
        algorithm = new Whirlpool();
        algorithm.update("abc".getBytes(), 0, 3);
        byte[] md = algorithm.digest();
        harness.check(TV2.equals(Util.toString(md)), "testABC");
      }
    catch (Exception x)
      {
        harness.debug(x);
        harness.fail("TestOfWhirlpool.testABC");
      }

    try
      {
        algorithm = new Whirlpool();
        algorithm.update("message digest".getBytes(), 0, 14);
        byte[] md = algorithm.digest();
        String exp = "378C84A4126E2DC6E56DCC7458377AAC838D00032230F53CE1F5700C0FFB4D3B"
                   + "8421557659EF55C106B4B52AC5A4AAA692ED920052838F3362E86DBD37A8903E";
        harness.check(exp.equals(Util.toString(md)), "testMessageDigest");
      }
    catch (Exception x)
      {
        harness.debug(x);
        harness.fail("TestOfWhirlpool.testMessageDigest");
      }

    try
      {
        algorithm = new Whirlpool();
        algorithm.update("abcdefghijklmnopqrstuvwxyz".getBytes(), 0, 26);
        byte[] md = algorithm.digest();
        String exp = "F1D754662636FFE92C82EBB9212A484A8D38631EAD4238F5442EE13B8054E41B"
                   + "08BF2A9251C30B6A0B8AAE86177AB4A6F68F673E7207865D5D9819A3DBA4EB3B";
        harness.check(exp.equals(Util.toString(md)), "testAlphabet");
      }
    catch (Exception x)
      {
        harness.debug(x);
        harness.fail("TestOfWhirlpool.testAlphabet");
      }

    try
      {
        algorithm = new Whirlpool();
        algorithm.update("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".getBytes(),
                         0,
                         62);
        byte[] md = algorithm.digest();
        String exp = "DC37E008CF9EE69BF11F00ED9ABA26901DD7C28CDEC066CC6AF42E40F82F3A1E"
                   + "08EBA26629129D8FB7CB57211B9281A65517CC879D7B962142C65F5A7AF01467";
        harness.check(exp.equals(Util.toString(md)), "testAsciiSubset");
      }
    catch (Exception x)
      {
        harness.debug(x);
        harness.fail("TestOfWhirlpool.testAsciiSubset");
      }

    try
      {
        algorithm = new Whirlpool();
        for (int i = 0; i < 8; i++)
          algorithm.update("1234567890".getBytes(), 0, 10);
        byte[] md = algorithm.digest();
        String exp = "466EF18BABB0154D25B9D38A6414F5C08784372BCCB204D6549C4AFADB601429"
                   + "4D5BD8DF2A6C44E538CD047B2681A51A2C60481E88C5A20B2C2A80CF3A9A083B";
        harness.check(exp.equals(Util.toString(md)), "testEightyNumerics");
      }
    catch (Exception x)
      {
        harness.debug(x);
        harness.fail("TestOfWhirlpool.testEightyNumerics");
      }

    try
      {
        algorithm = new Whirlpool();
        algorithm.update((byte) 'a');
        clone = (IMessageDigest) algorithm.clone();
        byte[] md = algorithm.digest();
        harness.check(TV1.equals(Util.toString(md)), "testCloning #1");
View Full Code Here

TOP

Related Classes of gnu.java.security.hash.Whirlpool

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.