Makes one-time-pad and substitution cipher real encryption compatible
All checks were successful
EpicKnarvik97/Books-Without-Borders/pipeline/head This commit looks good

This commit is contained in:
2025-08-18 18:02:57 +02:00
parent 6adec89ae1
commit cb70a8298d
10 changed files with 69 additions and 53 deletions

View File

@@ -13,21 +13,16 @@ public class AESTest {
String plainText = "Flåklypa";
String password = "TqOZdpY9RjjjVE9JjCWVecUYObv5MYidByrpI3cxjoY=";
System.out.println("Plaintext: " + plainText);
System.out.println("Encryption password: " + password);
AESConfiguration configuration = new AESConfiguration(new byte[]{-85, 103, -82, 71, 119, 28, 73, -75, -81, 102, -127, -125, -8, -75, 81, -111},
new byte[]{(byte) 104, -42, 63, 31, -120, -2, 14, -119, 35, 122, 109, -64, 122, 117, 33, -85}, password);
AES aes = new AES(configuration);
String cypherText = aes.encryptText(plainText);
System.out.println("Cypher text: " + cypherText);
assertNotNull(cypherText);
assertNotEquals(plainText, cypherText);
String decrypted = aes.decryptText(cypherText);
System.out.println("Decrypted: " + decrypted);
assertEquals(plainText, decrypted);
}

View File

@@ -12,8 +12,12 @@ public class GenenCryptTest {
@Test
public void encryptDecryptTest() {
String encryptionKey = EncryptionHelper.getNumberKeyFromStringKey("My secret password!");
String plaintext = "Very secret &4colored&r message.";
String plaintext = "Very secret &4colored&r message. That might be quite long. Of course, the length might " +
"cause problems, especially as the gene encryption requires several characters for every encrypted " +
"character. Also, the hexadecimal representation of the original text is encrypted. It is unknown if " +
"that might represent an increase in length.";
GenenCrypt genenCrypt = new GenenCrypt(encryptionKey);
genenCrypt.printCodonTable();
String cypherText = genenCrypt.encryptText(plaintext);

View File

@@ -10,8 +10,9 @@ public class OneTimePadTest {
@Test
public void oneTimePadTest() {
String plaintext = "Very secret text that should be kept secret";
String key = "Very secret key!";
String plaintext = "Very secret text that should be kept secret. It should be noted that several characters, " +
"like !\"#¤%&/()=?`§|@£${[]}'*,.-;:_<>µ need to be tested. Also foreign characters, like: øæåØÆÅ";
String key = "Very secret key that you will never guess!¤%&/";
OneTimePad oneTimePad = new OneTimePad(key);
String cypherText = oneTimePad.encryptText(plaintext);

View File

@@ -11,8 +11,9 @@ public class SubstitutionCipherTest {
@Test
public void encryptDecryptTest() {
String plaintext = "Very secret text that should be kept secret";
String integerKey = EncryptionHelper.getNumberKeyFromStringKey("Very secret key!");
String plaintext = "Very secret text that should be kept secret. It should be noted that several characters, " +
"like !\"#¤%&/()=?`§|@£${[]}'*,.-;:_<>µ need to be tested. Also foreign characters, like: øæåØÆÅ";
String integerKey = EncryptionHelper.getNumberKeyFromStringKey("Very secret key that you will never guess!¤%&/");
SubstitutionCipher substitutionCipher = new SubstitutionCipher(integerKey);
String cypherText = substitutionCipher.encryptText(plaintext);