@Override public String decrypt(String text) { // Null not allowed checkNotNull(text, "text"); // Decode the base64 text into bytes byte[] bytes = decodeBase64(getAsciiBytes(checkBase64(text))); // OpenSSL inserts the prefix "Salted__" followed by the salt itself int saltOffset = context.getSaltPrefix().length(); byte[] salt = copyOfRange(bytes, saltOffset, saltOffset + context.getSaltSize()); // encrypted bytes come after the prefix and the salt int encryptedBytesOffset = saltOffset + context.getSaltSize(); // extract the portion of the array containing the encrypted bytes byte[] encrypted = copyOfRange(bytes, encryptedBytesOffset, bytes.length); // decrypt the bytes using the salt that was embedded in the text byte[] decrypted = doCipher(context, DECRYPT_MODE, salt, encrypted, password); // Construct a string from the decrypted bytes return getUTF8String(decrypted); }