Created
May 11, 2016 21:07
-
-
Save Ninjex/40b80521bf850c04d6f9dfb78861ee6e to your computer and use it in GitHub Desktop.
Base64 Encode / Decode Script
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
def base64 | |
@data = params[:data] | |
@choice = params[:choice] | |
if !["encode", "decode"].include?(@choice) | |
render :action => 'base64' | |
end | |
end |
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
require 'base64' |
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
<%= form_tag("/tools/base64", method: "post") do %> | |
<%= label_tag(:input, "Data:") %><br> | |
<% if @choice == "encode" %> | |
<%= select_tag(:choice, options_for_select({'Encode' => 'encode', 'Decode' => 'decode'}, 'decode')) %><br> | |
<%= text_area_tag(:data, Base64.encode64(@data)) %><br> | |
<% elsif @choice == "decode" %> | |
<%= select_tag(:choice, options_for_select({'Encode' => 'encode', 'Decode' => 'decode'}, 'encode')) %><br> | |
<%= text_area_tag(:data, Base64.decode64(@data)) %><br> | |
<% else %> | |
<%= select_tag(:choice, options_for_select({'Encode' => 'encode', 'Decode' => 'decode'})) %><br> | |
<%= text_area_tag(:data)%><br> | |
<% end %> | |
<%= submit_tag("Convert") %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment