title: Why is openssl_decrypt adding escape slashes to the outputted data?
body: <p>I'm using openssl_encrypt to encrypt some JSON data before inserting it into an SQL DB.</p>
  <pre><code>$cypherMethod = 'AES-256-CBC';
  $key = 'WHATEVER';
  
  // Then we generate a random Initialization Vector - which is stored with record in DB
  
  $iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length($cypherMethod));
  
  // Now we run the encryption process and convert output to Base64 to make DB storage easier
  
  $userdata = openssl_encrypt($userdata, $cypherMethod, $key, $options=0, $iv);
  $userdata = base64_encode($userdata);
  </code></pre>
  <p>This works fine, and the data is then added to the DB.</p>
  <p>Then on the other end when I decrypt:</p>
  <pre><code>$cypherMethod = 'AES-256-CBC';
  $key = 'WHATEVER';
  $iv = 'GRABBED FROM DB RECORD';
  
  $userdata = base64_decode($userdata);
  $userdata = openssl_decrypt($userdata, $cypherMethod, $key, $options=0, $iv);
  </code></pre>
  <p>Now, the decryption process works fine, but by JSON data ends up with escape slashes, which I then have to remove with stripslashes().</p>
  <p>It's not a huge issue, but why are the slashes appearing? I know that Base64 adds slashes, but I'm only base64 encoding after the initial encryption, so I can't understand how the slashes make it into the underlying JSON data?</p>