diff --git a/lib/encryptor.rb b/lib/encryptor.rb index 0ade6d1b1851685f3d54bd167cf92fa72787fe8c..165ab91f2970147cbecbd553a1bcb004055e6847 100644 --- a/lib/encryptor.rb +++ b/lib/encryptor.rb @@ -16,7 +16,7 @@ module Encryptor cipher = OpenSSL::Cipher.new('AES-256-CBC') key = cipher.random_key iv = cipher.random_iv - {'key' => Base64.encode64s(key), 'iv' => Base64.encode64(iv)} + {'key' => Base64.encode64s(key), 'iv' => Base64.encode64s(iv)} end def aes_encrypt(txt, key) diff --git a/lib/salmon/salmon.rb b/lib/salmon/salmon.rb index aa0dd4b1de7861030d76f8aad7c766467fa3674c..3d09404d203ba89d5d63bc1d6f9b03a3901e948e 100644 --- a/lib/salmon/salmon.rb +++ b/lib/salmon/salmon.rb @@ -5,28 +5,12 @@ # Add URL safe Base64 support module Base64 module_function - # Returns the Base64-encoded version of +bin+. - # This method complies with RFC 4648. - # No line feeds are added. - def strict_encode64(bin) - [bin].pack("m0") - end - - # Returns the Base64-decoded version of +str+. - # This method complies with RFC 4648. - # ArgumentError is raised if +str+ is incorrectly padded or contains - # non-alphabet characters. Note that CR or LF are also rejected. - def strict_decode64(str) - Rails.logger.info("trying to decode string: " + str) - str.unpack("m0").first - end - # Returns the Base64-encoded version of +bin+. # This method complies with ``Base 64 Encoding with URL and Filename Safe # Alphabet'' in RFC 4648. # The alphabet uses '-' instead of '+' and '_' instead of '/'. def urlsafe_encode64(bin) - strict_encode64(bin).tr("+/", "-_") + self.encode64s(bin).tr("+/", "-_") end # Returns the Base64-decoded version of +str+. @@ -34,7 +18,7 @@ module Base64 # Alphabet'' in RFC 4648. # The alphabet uses '-' instead of '+' and '_' instead of '/'. def urlsafe_decode64(str) - strict_decode64(str.tr("-_", "+/")) + self.decode64(str.tr("-_", "+/")) end end