}\r
}\r
\r
+ @Test\r
+ public void test1() throws CadiException {\r
+ String init = "m8234337@csp.att.com:kumquat8rie@#Tomatos3";\r
+ String hashed = Hash.toHex(init.getBytes());\r
+ System.out.println(hashed);\r
+ byte[] ba = Hash.fromHex(hashed);\r
+ String recon = new String(ba);\r
+ System.out.println(recon);\r
+ Assert.assertEquals(init, recon);\r
+ \r
+ init =hashed.substring(1);\r
+ try {\r
+ hashed = Hash.fromHex(init).toString();\r
+ Assert.fail("Should have thrown Exception");\r
+ } catch (CadiException e) {\r
+ \r
+ }\r
+ \r
+ init = hashed.replace('1', '~');\r
+ try {\r
+ hashed = Hash.fromHex(init).toString();\r
+ Assert.fail("Should have thrown Exception");\r
+ } catch (CadiException e) {\r
+ \r
+ }\r
+ }\r
+\r
+ \r
+ @Test\r
+ public void test2() throws CadiException {\r
+ String init = "m823475@csp.att.com:kumquat8rie@#Tomatos3";\r
+ String hashed = Hash.toHex(init.getBytes());\r
+ System.out.println(hashed);\r
+ byte[] ba = Hash.fromHex(hashed);\r
+ String recon = new String(ba);\r
+ System.out.println(recon);\r
+ Assert.assertEquals(init, recon);\r
+ \r
+ init =hashed.substring(1);\r
+ try {\r
+ hashed = Hash.fromHex(init).toString();\r
+ Assert.fail("Should have thrown Exception");\r
+ } catch (CadiException e) {\r
+ \r
+ }\r
+ \r
+ init = hashed.replace('1', '~');\r
+ try {\r
+ hashed = Hash.fromHex(init).toString();\r
+ Assert.fail("Should have thrown Exception");\r
+ } catch (CadiException e) {\r
+ \r
+ }\r
+ }\r
+\r
}\r