Documentation for a third-party API I'm working with states with:
"[O] ur API allows only filled Base64 encoded strings."
What are Base64 encoded filled strings and how can I generate them in Ruby. The code below is my first attempt at creating formatted JSON data converted to Base64.
xa = Base64.encode64(a.to_json)
The gasket they are talking about is actually part of Base64 itself. This is "=" and "==" at the end. Base64 encodes packets of 3 bytes into 4 encoded characters. Therefore, if your input is n and
.
base64; padding Base64 = .
base64
=
, irb :
irb(main):002:0> require 'base64' => true irb(main):003:0> Base64.encode64('a') => "YQ==\n"
, , YQ - - .
YQ