Created
February 20, 2022 23:26
-
-
Save profh/03bb7c768dac0cc2c588d3619516e3c3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 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