示例#1
0
 /** Test of sign method, of class HMacMD5. */
 @Test
 public void testSign() {
   System.out.println("sign");
   byte[] msg = "Olá como vai isso?".getBytes();
   byte[] key = "chave privata simétrica".getBytes();
   HMacMD5 instance = new HMacMD5();
   byte[] expResult = instance.sign(msg, key);
   byte[] result = instance.sign(msg, key);
   System.out.println(new String(result));
   System.out.println(new String(expResult));
   assertArrayEquals(expResult, result);
 }
示例#2
0
 /** Test of sign method, of class HMacMD5. */
 @Test
 public void testSignWithDiffKeys() {
   System.out.println("sign with diff keys");
   byte[] msg = "Olá como vai isso?".getBytes();
   byte[] key = "chave privata simétrica".getBytes();
   byte[] key2 = "chave privata simétrica2".getBytes();
   HMacMD5 instance = new HMacMD5();
   byte[] expResult = instance.sign(msg, key2);
   byte[] result = instance.sign(msg, key);
   System.out.println(new String(result));
   System.out.println(new String(expResult));
   Assert.assertThat(result, IsNot.not(IsEqual.equalTo(expResult)));
 }