title: Is it possible to pipe a file with quotes and special characters to OpenSSL?
body: <p>I am trying to write a bash script that will allow the user to input a password, and then pipe stdin (either via terminal commands or a piped file) to ‘openssl enc’ to encrypt it line by line using that password, and then finally pipe it out to an external TCP server. </p>
  
  <p>This is what I have so far, and it mostly works:</p>
  
  <pre><code>#!/bin/bash
  printf "What is your encryption 
  password?\n"
  read -s password &lt;/dev/tty
  while read line; do echo "$line" | openssl enc -aes-256-cbc -base64 -pass pass:$password -e; done &gt; &gt;(openssl s_client -quiet -connect localhost:3001)
  </code></pre>
  
  <p>You run this via cat file | script.sh.</p>
  
  <p>The problem I’m running into is when the file has quotes or special characters in it and breaks the echo. </p>
  
  <p>Is there a way to get around this?</p>