@Test(priority = 6) public void testDecrypt() { String input = "EncryptMe"; String encrypted = cryptoTool.encrypt(input); String decrypted = cryptoTool.decrypt(encrypted); Assert.assertNotNull(decrypted); Assert.assertEquals(input, decrypted); }
public String decrypt(String strToDecrypt) { try { cipher.init(Cipher.DECRYPT_MODE, key); final String decryptedString = new String(cipher.doFinal(Base64.decodeBase64(strToDecrypt.getBytes()))); return decryptedString; } catch (Exception e) { throw new RuntimeException("Error while decrypting, check your crypto key! " + e.getMessage(), e); } }
CryptoTool { public String decrypt(String strToDecrypt) { try { cipher.init(Cipher.DECRYPT_MODE, key); final String decryptedString = new String(cipher.doFinal(Base64.decodeBase64(strToDecrypt.getBytes()))); return decryptedString; } catch (Exception e) { throw new RuntimeException("Error while decrypting, check your crypto key! " + e.getMessage(), e); } } }
CryptoTool { public String decrypt(String strToDecrypt) { try { cipher.init(Cipher.DECRYPT_MODE, key); final String decryptedString = new String(cipher.doFinal(Base64.decodeBase64(strToDecrypt.getBytes()))); return decryptedString; } catch (Exception e) { throw new RuntimeException("Error while decrypting, check your crypto key! " + e.getMessage(), e); } } CryptoTool(String cryptoAlgorithm, String cryptoKeyType, Key key);  CryptoTool();  CryptoTool(String cryptoKeyPath);  CryptoTool(String cryptoAlgorithm, String cryptoKeyType, String cryptoKeyPath); }
CryptoTool { public String decrypt(String strToDecrypt) { try { cipher.init(Cipher.DECRYPT_MODE, key); final String decryptedString = new String(cipher.doFinal(Base64.decodeBase64(strToDecrypt.getBytes()))); return decryptedString; } catch (Exception e) { throw new RuntimeException("Error while decrypting, check your crypto key! " + e.getMessage(), e); } } CryptoTool(String cryptoAlgorithm, String cryptoKeyType, Key key);  CryptoTool();  CryptoTool(String cryptoKeyPath);  CryptoTool(String cryptoAlgorithm, String cryptoKeyType, String cryptoKeyPath); String encrypt(String strToEncrypt); String decrypt(String strToDecrypt); String encryptByPattern(String content, Pattern pattern); String decryptByPattern(String content, Pattern pattern); String encryptByPatternAndWrap(String content, Pattern pattern, String wrapper); String decryptByPatternAndWrap(String content, Pattern pattern, String wrapper); String getAlgorithm(); void setAlgorithm(String algorithm); Cipher getCipher(); void setCipher(Cipher cipher); }
CryptoTool { public String decrypt(String strToDecrypt) { try { cipher.init(Cipher.DECRYPT_MODE, key); final String decryptedString = new String(cipher.doFinal(Base64.decodeBase64(strToDecrypt.getBytes()))); return decryptedString; } catch (Exception e) { throw new RuntimeException("Error while decrypting, check your crypto key! " + e.getMessage(), e); } } CryptoTool(String cryptoAlgorithm, String cryptoKeyType, Key key);  CryptoTool();  CryptoTool(String cryptoKeyPath);  CryptoTool(String cryptoAlgorithm, String cryptoKeyType, String cryptoKeyPath); String encrypt(String strToEncrypt); String decrypt(String strToDecrypt); String encryptByPattern(String content, Pattern pattern); String decryptByPattern(String content, Pattern pattern); String encryptByPatternAndWrap(String content, Pattern pattern, String wrapper); String decryptByPatternAndWrap(String content, Pattern pattern, String wrapper); String getAlgorithm(); void setAlgorithm(String algorithm); Cipher getCipher(); void setCipher(Cipher cipher);  }