Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/ExeBy/exe_root.../opt/alt/ruby22/lib64/ruby/2.2.0
File: base64.rb
#
[0] Fix | Delete
# = base64.rb: methods for base64-encoding and -decoding strings
[1] Fix | Delete
#
[2] Fix | Delete
[3] Fix | Delete
# The Base64 module provides for the encoding (#encode64, #strict_encode64,
[4] Fix | Delete
# #urlsafe_encode64) and decoding (#decode64, #strict_decode64,
[5] Fix | Delete
# #urlsafe_decode64) of binary data using a Base64 representation.
[6] Fix | Delete
#
[7] Fix | Delete
# == Example
[8] Fix | Delete
#
[9] Fix | Delete
# A simple encoding and decoding.
[10] Fix | Delete
#
[11] Fix | Delete
# require "base64"
[12] Fix | Delete
#
[13] Fix | Delete
# enc = Base64.encode64('Send reinforcements')
[14] Fix | Delete
# # -> "U2VuZCByZWluZm9yY2VtZW50cw==\n"
[15] Fix | Delete
# plain = Base64.decode64(enc)
[16] Fix | Delete
# # -> "Send reinforcements"
[17] Fix | Delete
#
[18] Fix | Delete
# The purpose of using base64 to encode data is that it translates any
[19] Fix | Delete
# binary data into purely printable characters.
[20] Fix | Delete
[21] Fix | Delete
module Base64
[22] Fix | Delete
module_function
[23] Fix | Delete
[24] Fix | Delete
# Returns the Base64-encoded version of +bin+.
[25] Fix | Delete
# This method complies with RFC 2045.
[26] Fix | Delete
# Line feeds are added to every 60 encoded characters.
[27] Fix | Delete
#
[28] Fix | Delete
# require 'base64'
[29] Fix | Delete
# Base64.encode64("Now is the time for all good coders\nto learn Ruby")
[30] Fix | Delete
#
[31] Fix | Delete
# <i>Generates:</i>
[32] Fix | Delete
#
[33] Fix | Delete
# Tm93IGlzIHRoZSB0aW1lIGZvciBhbGwgZ29vZCBjb2RlcnMKdG8gbGVhcm4g
[34] Fix | Delete
# UnVieQ==
[35] Fix | Delete
def encode64(bin)
[36] Fix | Delete
[bin].pack("m")
[37] Fix | Delete
end
[38] Fix | Delete
[39] Fix | Delete
# Returns the Base64-decoded version of +str+.
[40] Fix | Delete
# This method complies with RFC 2045.
[41] Fix | Delete
# Characters outside the base alphabet are ignored.
[42] Fix | Delete
#
[43] Fix | Delete
# require 'base64'
[44] Fix | Delete
# str = 'VGhpcyBpcyBsaW5lIG9uZQpUaGlzIG' +
[45] Fix | Delete
# 'lzIGxpbmUgdHdvClRoaXMgaXMgbGlu' +
[46] Fix | Delete
# 'ZSB0aHJlZQpBbmQgc28gb24uLi4K'
[47] Fix | Delete
# puts Base64.decode64(str)
[48] Fix | Delete
#
[49] Fix | Delete
# <i>Generates:</i>
[50] Fix | Delete
#
[51] Fix | Delete
# This is line one
[52] Fix | Delete
# This is line two
[53] Fix | Delete
# This is line three
[54] Fix | Delete
# And so on...
[55] Fix | Delete
def decode64(str)
[56] Fix | Delete
str.unpack("m").first
[57] Fix | Delete
end
[58] Fix | Delete
[59] Fix | Delete
# Returns the Base64-encoded version of +bin+.
[60] Fix | Delete
# This method complies with RFC 4648.
[61] Fix | Delete
# No line feeds are added.
[62] Fix | Delete
def strict_encode64(bin)
[63] Fix | Delete
[bin].pack("m0")
[64] Fix | Delete
end
[65] Fix | Delete
[66] Fix | Delete
# Returns the Base64-decoded version of +str+.
[67] Fix | Delete
# This method complies with RFC 4648.
[68] Fix | Delete
# ArgumentError is raised if +str+ is incorrectly padded or contains
[69] Fix | Delete
# non-alphabet characters. Note that CR or LF are also rejected.
[70] Fix | Delete
def strict_decode64(str)
[71] Fix | Delete
str.unpack("m0").first
[72] Fix | Delete
end
[73] Fix | Delete
[74] Fix | Delete
# Returns the Base64-encoded version of +bin+.
[75] Fix | Delete
# This method complies with ``Base 64 Encoding with URL and Filename Safe
[76] Fix | Delete
# Alphabet'' in RFC 4648.
[77] Fix | Delete
# The alphabet uses '-' instead of '+' and '_' instead of '/'.
[78] Fix | Delete
def urlsafe_encode64(bin)
[79] Fix | Delete
strict_encode64(bin).tr("+/", "-_")
[80] Fix | Delete
end
[81] Fix | Delete
[82] Fix | Delete
# Returns the Base64-decoded version of +str+.
[83] Fix | Delete
# This method complies with ``Base 64 Encoding with URL and Filename Safe
[84] Fix | Delete
# Alphabet'' in RFC 4648.
[85] Fix | Delete
# The alphabet uses '-' instead of '+' and '_' instead of '/'.
[86] Fix | Delete
def urlsafe_decode64(str)
[87] Fix | Delete
strict_decode64(str.tr("-_", "+/"))
[88] Fix | Delete
end
[89] Fix | Delete
end
[90] Fix | Delete
[91] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function