@Test public void testEncryptDecrypt256_HugeData() { System.out.println("encrypt and decrypt huge Data"); byte[] plainInput = new byte[1000000]; KeyGenSHA3 keyGen = new KeyGenSHA3(); String hexKey = keyGen.generateKey(256, "password"); byte[] bKey = CryptobyHelper.hexStringToBytes(hexKey); CryptAES instance = new CryptAES(); byte[] expResult = plainInput; byte[] result = instance.encrypt(plainInput, bKey); result = instance.decrypt(result, bKey); assertArrayEquals(expResult, result); }
@Test public void testEncryptDecrypt256() { System.out.println("encrypt and decrypt testphrase"); byte[] plainInput = "Text to Test for Testing from Tester by Testcase".getBytes(); KeyGenSHA3 keyGen = new KeyGenSHA3(); String hexKey = keyGen.generateKey(256, "password"); byte[] bKey = CryptobyHelper.hexStringToBytes(hexKey); CryptAES instance = new CryptAES(); byte[] expResult = plainInput; byte[] result = instance.encrypt(plainInput, bKey); result = instance.decrypt(result, bKey); assertArrayEquals(expResult, result); }
@Test public void testEncryptDecrypt256_CBC() { System.out.println("encrypt and decrypt recurring words"); byte[] plainInput = "TestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTest".getBytes(); KeyGenSHA3 keyGen = new KeyGenSHA3(); String hexKey = keyGen.generateKey(256, "password"); byte[] bKey = CryptobyHelper.hexStringToBytes(hexKey); CryptAES instance = new CryptAES(); byte[] expResult = plainInput; byte[] result = instance.encrypt(plainInput, bKey); String resString = CryptobyHelper.bytesToHexStringUpper(result); for (int i = 0; i < resString.length() - 32; i += 32) { assertFalse(resString.substring(i, i + 32).equals(resString.substring(i + 32, i + 64))); } result = instance.decrypt(result, bKey); assertArrayEquals(expResult, result); }