1 19 20 package org.lucane.common.crypto; 21 22 import junit.framework.*; 23 24 public class BlowFishTest extends TestCase 25 { 26 public BlowFishTest(String title) 27 { 28 super(title); 29 } 30 31 public void testCipherDecipher() 32 { 33 String key = "someKey"; 34 String passwd = "aPassword"; 35 String ciphered = ""; 36 String deciphered = ""; 37 38 try { 39 ciphered = BlowFish.cipher(key, passwd); 40 deciphered = BlowFish.decipher(key, ciphered); 41 } catch(CryptoException ce) { 42 Assert.fail(ce.getMessage()); 43 } 44 45 Assert.assertEquals(passwd, deciphered); 46 } 47 48 public void testLongKey() 49 { 50 String key = "aKeyThatIsReallyTooLongToUseCorrectly"; 51 String passwd = "aPassword"; 52 String ciphered = ""; 53 String deciphered = ""; 54 55 try { 56 ciphered = BlowFish.cipher(key, passwd); 57 deciphered = BlowFish.decipher(key, ciphered); 58 } catch(CryptoException ce) { 59 Assert.fail(ce.getMessage()); 60 } 61 62 Assert.assertEquals(passwd, deciphered); 63 } 64 } | Popular Tags |