/ Published in: Ruby
Expand |
Embed | Plain Text
def decode_base64( text ) text.unpack( "m" )[0] end def encode_base64( bin ) [ bin ].pack( "m" ).gsub( /\s/, "" ) end text = "The quick brown fox jumps over the lazy dog" p encode_base64( text ) # => VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw== p decode_base64( encode_base64( text ) ) # => The quick brown fox jumps over the lazy dog
You need to login to post a comment.
