Module: Base64
- Defined in:
- lib/ronin/formatting/extensions/binary/base64.rb
Overview
Adds Ruby 1.9 specific methods when running on Ruby 1.8.7.
Class Method Summary collapse
-
.strict_decode64(str) ⇒ String
Decodes a strictly base64 encoded String.
-
.strict_encode64(bin) ⇒ String
Strictly encodes a base64 String.
-
.urlsafe_decode64(str) ⇒ String
Decodes a URL-safe base64 encoded String.
-
.urlsafe_encode64(bin) ⇒ String
Encodes a URL-safe base64 String.
Class Method Details
.strict_decode64(str) ⇒ String
This method complies with RFC 4648.
Decodes a strictly base64 encoded String.
62 63 64 65 66 67 68 |
# File 'lib/ronin/formatting/extensions/binary/base64.rb', line 62 def strict_decode64(str) unless str.include?("\n") decode64(str) else raise(ArgumentError,"invalid base64") end end |
.strict_encode64(bin) ⇒ String
This method complies with RFC 4648. No line feeds are added.
Strictly encodes a base64 String.
42 43 44 |
# File 'lib/ronin/formatting/extensions/binary/base64.rb', line 42 def strict_encode64(bin) encode64(bin).tr("\n",'') end |
.urlsafe_decode64(str) ⇒ String
This method complies with ``Base 64 Encoding with URL and filename Safe Alphabet’’ in RFC 4648. The alphabet uses ‘-‘ instead of ‘+’ and ‘_’ instead of ‘/’.
Decodes a URL-safe base64 encoded String.
102 103 104 |
# File 'lib/ronin/formatting/extensions/binary/base64.rb', line 102 def urlsafe_decode64(str) strict_decode64(str.tr("-_", "+/")) end |
.urlsafe_encode64(bin) ⇒ String
This method complies with ``Base 64 Encoding with URL and filename Safe Alphabet’’ in RFC 4648. The alphabet uses ‘-‘ instead of ‘+’ and ‘_’ instead of ‘/’.
Encodes a URL-safe base64 String.
84 85 86 |
# File 'lib/ronin/formatting/extensions/binary/base64.rb', line 84 def urlsafe_encode64(bin) strict_encode64(bin).tr("+/", "-_") end |