Skip to content

Instantly share code, notes, and snippets.

@profh
Created February 20, 2022 23:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save profh/03bb7c768dac0cc2c588d3619516e3c3 to your computer and use it in GitHub Desktop.
Save profh/03bb7c768dac0cc2c588d3619516e3c3 to your computer and use it in GitHub Desktop.
### A Quick Base64 Encode/Decode Demo ###
# require Ruby's base64 library
require 'base64'
# Create a message (Zach Synder's Justice League cast)
heroes = %w[Batman Superman Wonder\ Woman Flash Aquaman Cyborg]
message = "Justice League: #{heroes.join(', ')}."
# Base74 encoding of the message
encoded_message = Base64.encode64(message)
puts "Encoded: "
puts encoded_message
# Time to decode the base64 string
decoded_message = Base64.decode64(encoded_message)
puts "Decoded: "
puts decoded_message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment