lib/ctf_party/base64.rb in ctf-party-1.0.0 vs lib/ctf_party/base64.rb in ctf-party-1.1.0
- old
+ new
@@ -25,15 +25,11 @@
# @example
# myStr = 'Ruby' # => "Ruby"
# myStr.to_b64! # => nil
# myStr # => "UnVieQ=="
def to_b64!(opts = {})
- opts[:mode] ||= :strict
- replace(to_b64) if opts[:mode] == :strict ||
- opts[:mode] == :rfc4648
- replace(to_b64(mode: :rfc2045)) if opts[:mode] == :rfc2045
- replace(to_b64(mode: :urlsafe)) if opts[:mode] == :urlsafe
+ replace(to_b64(opts))
end
# Decode the string from base64
# @param opts [Hash] optional parameters
# @option opts [Symbol] :mode Default value: +:strict+.
@@ -55,14 +51,10 @@
# @example
# a = 'SGVsbG8gd29ybGQh' # => "SGVsbG8gd29ybGQh"
# a.from_b64! # => nil
# a # => "Hello world!"
def from_b64!(opts = {})
- opts[:mode] ||= :strict
- replace(from_b64) if opts[:mode] == :strict ||
- opts[:mode] == :rfc4648
- replace(from_b64(mode: :rfc2045)) if opts[:mode] == :rfc2045
- replace(from_b64(mode: :urlsafe)) if opts[:mode] == :urlsafe
+ replace(from_b64(opts))
end
# Is the string encoded in base64?
# @param opts [Hash] optional parameters
# @option opts [Symbol] :mode Default value: +:strict+.