1

I know I can translate any binary data into purely printable characters with Base64.encode64 and translate it back to binary data with Base64.decode64.

But is there any way to check if the data is translated into printable characters with Base64.encode64??

For instance, I'm looking for something like the code below.

str = Base64.encode("test")
p str.encoded? #=> true

https://ruby-doc.org/stdlib-2.1.3/libdoc/base64/rdoc/Base64.html

K-Sato
  • 400
  • 7
  • 26
  • You're asking if there's a way to confirm that the output of `Base64.encode` consists only of printable characters? Base64, [by definition](https://en.wikipedia.org/wiki/Base64), consists only of printable characters. – anothermh Apr 12 '19 at 02:21
  • 1
    @anothermh Sorry for the confusion. I guess what I'm asking here is if there is any way to differentiate a normal printable string like `"test"` from a printable string that was originally binary and got translated into a printable string using `Base64encode64`. – K-Sato Apr 12 '19 at 02:27
  • 1
    [This](https://stackoverflow.com/q/8571501/3784008) and [this](https://stackoverflow.com/q/30476873/3784008) answer this question thoroughly, and are easily found by searching. – anothermh Apr 12 '19 at 02:32

0 Answers0