|
@ -5,6 +5,7 @@ package com.ugsbo.Crypto; |
|
|
|
|
|
|
|
|
import com.ugsbo.Crypto.*; |
|
|
import com.ugsbo.Crypto.*; |
|
|
import static org.junit.Assert.*; |
|
|
import static org.junit.Assert.*; |
|
|
|
|
|
import java.io.UnsupportedEncodingException; |
|
|
import java.security.GeneralSecurityException; |
|
|
import java.security.GeneralSecurityException; |
|
|
import java.security.NoSuchAlgorithmException; |
|
|
import java.security.NoSuchAlgorithmException; |
|
|
import org.junit.Before; |
|
|
import org.junit.Before; |
|
@ -25,15 +26,17 @@ public class Crypt { |
|
|
|
|
|
|
|
|
String eingabe = "TestText"; |
|
|
String eingabe = "TestText"; |
|
|
String ergebnis; |
|
|
String ergebnis; |
|
|
|
|
|
String password = ""; |
|
|
|
|
|
|
|
|
workingobjekt.setOffen(eingabe); |
|
|
|
|
|
try { |
|
|
try { |
|
|
workingobjekt.verschlüsseln(); |
|
|
|
|
|
} catch (NoSuchAlgorithmException e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} catch (GeneralSecurityException e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
workingobjekt.setOffen(eingabe); |
|
|
|
|
|
workingobjekt.setPassword(password); |
|
|
|
|
|
workingobjekt.entschlüsseln(); |
|
|
|
|
|
} catch (GeneralSecurityException e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} catch (UnsupportedEncodingException e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
ergebnis = workingobjekt.getVerschlüsselt(); |
|
|
ergebnis = workingobjekt.getVerschlüsselt(); |
|
|
|
|
|
|
|
@ -43,16 +46,18 @@ public class Crypt { |
|
|
@Test |
|
|
@Test |
|
|
public void verUndEntschlüsseln() { |
|
|
public void verUndEntschlüsseln() { |
|
|
|
|
|
|
|
|
|
|
|
String password = "Test"; |
|
|
String eingabe = "TestText"; |
|
|
String eingabe = "TestText"; |
|
|
String ergebnis; |
|
|
String ergebnis; |
|
|
|
|
|
|
|
|
workingobjekt.setOffen(eingabe); |
|
|
|
|
|
try { |
|
|
try { |
|
|
|
|
|
workingobjekt.setOffen(eingabe); |
|
|
|
|
|
workingobjekt.setPassword(password); |
|
|
|
|
|
workingobjekt.entschlüsseln(); |
|
|
workingobjekt.verschlüsseln(); |
|
|
workingobjekt.verschlüsseln(); |
|
|
} catch (GeneralSecurityException e) { |
|
|
|
|
|
|
|
|
} catch (GeneralSecurityException | UnsupportedEncodingException e) { |
|
|
e.printStackTrace(); |
|
|
e.printStackTrace(); |
|
|
} |
|
|
} |
|
|
workingobjekt.entschlüsseln(); |
|
|
|
|
|
ergebnis = workingobjekt.getOffen(); |
|
|
ergebnis = workingobjekt.getOffen(); |
|
|
|
|
|
|
|
|
assertEquals("das entschlüsselte Test Wort",ergebnis,eingabe); |
|
|
assertEquals("das entschlüsselte Test Wort",ergebnis,eingabe); |
|
|