Adds a class for AES encryption which might be used instead of the current encryption methods

This commit is contained in:
2021-09-04 20:21:00 +02:00
parent 48ac82f4d4
commit a9f2017a40
2 changed files with 182 additions and 0 deletions

View File

@ -0,0 +1,23 @@
package net.knarcraft.bookswithoutborders.encryption;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
public class AESTest {
@Test
public void encryptDecryptTest() {
String plainText = "A lot of text";
String password = "abc123";
AES aes = new AES(AES.generateIV(), AES.generateIV());
String encrypted = aes.encryptDecryptText(plainText, password, true);
assertFalse(encrypted.equals(plainText));
String decrypted = aes.encryptDecryptText(encrypted, password, false);
assertEquals(plainText, decrypted);
}
}