title: Strange \n in base64 encoded string in Ruby
body: <p>The inbuilt Base64 library in Ruby is adding some '\n's. I'm unable to find out the reason. For this special example:</p>
  
  <pre><code>irb(main):001:0&gt; require 'rubygems'
  =&gt; true
  irb(main):002:0&gt; require 'base64'
  =&gt; true
  irb(main):003:0&gt; str =  "1110--ad6ca0b06e1fbeb7e6518a0418a73a6e04a67054"
  =&gt; "1110--ad6ca0b06e1fbeb7e6518a0418a73a6e04a67054"
  irb(main):004:0&gt; Base64.encode64(str)
  =&gt; "MTExMC0tYWQ2Y2EwYjA2ZTFmYmViN2U2NTE4YTA0MThhNzNhNmUwNGE2NzA1\nNA==\n"
  </code></pre>
  
  <p>The \n's are at the last and 6th position from end. The decoder (Base64.decode64) returns back the old string perfectly. Strange thing is, these \n's don't add any value to the encoded string. When I remove the newlines from the output string, the decoder decodes it again perfectly.</p>
  
  <pre><code>irb(main):005:0&gt; Base64.decode64(Base64.encode64(str).gsub("\n", '')) == str
  =&gt; true
  </code></pre>
  
  <p>More of this, I used an another JS library to produce the base64 encoded output of the same input string, the output comes without the \n's.</p>
  
  <p>Is this a bug or anything else? Has anybody faced this issue before?</p>
  
  <p>FYI,</p>
  
  <pre><code>$ ruby -v
  ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]
  </code></pre>