Advertisement
pellekrogholt

Untitled

Nov 9th, 2011
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.86 KB | None | 0 0
  1. package lecture8_security.pellekrogholt;
  2.  
  3. import java.util.ArrayList;
  4.  
  5. import junit.framework.Assert;
  6.  
  7. import org.junit.Test;
  8.  
  9. public class SymmetricCryptTest {
  10.     private static final String password = "bdsp08-06";
  11.     private static final String plaintext = "The quick brown fox jumps over the lazy dog.";
  12.     private SymmetricCrypt crypt = new SymmetricCrypt(password);
  13.    
  14.  
  15.     @Test
  16.     /***
  17.      * Static implementation of cryptation and encryption methods
  18.      */
  19.     public void TestCryptHelper() throws Exception {
  20.         // Create Key
  21.         byte key[] = password.getBytes();
  22.         CryptHelper.writeFile( CryptHelper.encrypt(key, plaintext), "output.txt");
  23.         CryptHelper.writeFile(plaintext.getBytes(), "unsecure.txt");
  24.        
  25.  
  26.         String decrypted = CryptHelper.decrypt(key, CryptHelper.readFile("output.txt"));
  27.         // Compare
  28.        
  29.         Assert.assertEquals(plaintext, decrypted);
  30.        
  31.     }
  32.  
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement