@Test(expectedExceptions = SakuliCipherException.class, expectedExceptionsMessageRegExp = "Provided AES key is null or empty") public void testKeyNullDecrypt() throws Exception { AesCbcCipher.decryptString("bkkala", null); }
public static String decryptString(String encryptedStringBase64, SecretKey aesKey) throws SakuliCipherException { if (StringUtils.isEmpty(encryptedStringBase64)) { throw new SakuliCipherException("Empty secret can not en-/decrypted!"); } final byte[] ciphertext; try { ciphertext = new BASE64Decoder().decodeBuffer(encryptedStringBase64); } catch (IOException e) { throw new SakuliCipherException("Can not decrypt invalid Base64 secret: " + encryptedStringBase64); } final byte[] decrypted = decryptBytes(aesKey, ciphertext); return convertBytesToString(decrypted); }
AesCbcCipher { public static String decryptString(String encryptedStringBase64, SecretKey aesKey) throws SakuliCipherException { if (StringUtils.isEmpty(encryptedStringBase64)) { throw new SakuliCipherException("Empty secret can not en-/decrypted!"); } final byte[] ciphertext; try { ciphertext = new BASE64Decoder().decodeBuffer(encryptedStringBase64); } catch (IOException e) { throw new SakuliCipherException("Can not decrypt invalid Base64 secret: " + encryptedStringBase64); } final byte[] decrypted = decryptBytes(aesKey, ciphertext); return convertBytesToString(decrypted); } }
AesCbcCipher { public static String decryptString(String encryptedStringBase64, SecretKey aesKey) throws SakuliCipherException { if (StringUtils.isEmpty(encryptedStringBase64)) { throw new SakuliCipherException("Empty secret can not en-/decrypted!"); } final byte[] ciphertext; try { ciphertext = new BASE64Decoder().decodeBuffer(encryptedStringBase64); } catch (IOException e) { throw new SakuliCipherException("Can not decrypt invalid Base64 secret: " + encryptedStringBase64); } final byte[] decrypted = decryptBytes(aesKey, ciphertext); return convertBytesToString(decrypted); }  }
AesCbcCipher { public static String decryptString(String encryptedStringBase64, SecretKey aesKey) throws SakuliCipherException { if (StringUtils.isEmpty(encryptedStringBase64)) { throw new SakuliCipherException("Empty secret can not en-/decrypted!"); } final byte[] ciphertext; try { ciphertext = new BASE64Decoder().decodeBuffer(encryptedStringBase64); } catch (IOException e) { throw new SakuliCipherException("Can not decrypt invalid Base64 secret: " + encryptedStringBase64); } final byte[] decrypted = decryptBytes(aesKey, ciphertext); return convertBytesToString(decrypted); }  static IvParameterSpec createIV(final int ivSizeBytes, final Optional<SecureRandom> rng); static IvParameterSpec readIV(final int ivSizeBytes, final InputStream is); static byte[] decryptBytes(SecretKey aesKey, byte[] ciphertext); static byte[] encryptBytes(SecureRandom rng, SecretKey aesKey, byte[] plaintext); static String encryptString(String secret, SecretKey aesKey); static String decryptString(String encryptedStringBase64, SecretKey aesKey); }
AesCbcCipher { public static String decryptString(String encryptedStringBase64, SecretKey aesKey) throws SakuliCipherException { if (StringUtils.isEmpty(encryptedStringBase64)) { throw new SakuliCipherException("Empty secret can not en-/decrypted!"); } final byte[] ciphertext; try { ciphertext = new BASE64Decoder().decodeBuffer(encryptedStringBase64); } catch (IOException e) { throw new SakuliCipherException("Can not decrypt invalid Base64 secret: " + encryptedStringBase64); } final byte[] decrypted = decryptBytes(aesKey, ciphertext); return convertBytesToString(decrypted); }  static IvParameterSpec createIV(final int ivSizeBytes, final Optional<SecureRandom> rng); static IvParameterSpec readIV(final int ivSizeBytes, final InputStream is); static byte[] decryptBytes(SecretKey aesKey, byte[] ciphertext); static byte[] encryptBytes(SecureRandom rng, SecretKey aesKey, byte[] plaintext); static String encryptString(String secret, SecretKey aesKey); static String decryptString(String encryptedStringBase64, SecretKey aesKey); static final String CBC_ALGORITHM; }