diaspora/lib/salmon/salmon.rb
Steven Hancock a8de3a5a3f Rails.root and File.join cleanup
- `Rails.root` is a `Pathname`, so let's use `Rails.root.join`
- Clean up most of the remaining `File.join`s
2012-06-11 03:13:20 -07:00

30 lines
1.1 KiB
Ruby

# Copyright (c) 2010-2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
# Add URL safe Base64 support
module Base64
module_function
# 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)
self.strict_encode64(bin).tr("+/", "-_")
end
# Returns the Base64-decoded version of +str+.
# 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_decode64(str)
self.decode64(str.tr("-_", "+/"))
end
end
# Verify documents secured with Magic Signatures
module Salmon
autoload :Slap, Rails.root.join("lib", "salmon", "slap")
autoload :EncryptedSlap, Rails.root.join("lib", "salmon", "encrypted_slap")
autoload :MagicSigEnvelope, Rails.root.join("lib", "salmon", "magic_sig_envelope")
end