Adds a class for AES encryption which might be used instead of the current encryption methods
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user