change Base64.encode64 to Base64.encode64s (encode without newlines)

This commit is contained in:
danielgrippi 2011-08-31 16:26:02 -07:00 committed by Ilya Zhitomirskiy
parent 58abbcc058
commit 36f5e45c25
5 changed files with 8 additions and 7 deletions

View file

@ -9,5 +9,5 @@
<Link rel='http://webfinger.net/rel/profile-page' type='text/html' <%="#{person_href(@person, :absolute => true)}"%>/> <Link rel='http://webfinger.net/rel/profile-page' type='text/html' <%="#{person_href(@person, :absolute => true)}"%>/>
<Link rel="http://schemas.google.com/g/2010#updates-from" type="application/atom+xml" href="<%=@person.public_url%>.atom"/> <Link rel="http://schemas.google.com/g/2010#updates-from" type="application/atom+xml" href="<%=@person.public_url%>.atom"/>
<Link rel="diaspora-public-key" type = 'RSA' href="<%=Base64.encode64(@person.exported_key)%>"/> <Link rel="diaspora-public-key" type = 'RSA' href="<%=Base64.encode64s(@person.exported_key)%>"/>
</XRD> </XRD>

View file

@ -26,7 +26,7 @@ module Diaspora
# @param [OpenSSL::PKey::RSA] key An RSA key # @param [OpenSSL::PKey::RSA] key An RSA key
# @return [String] A Base64 encoded signature of #signable_string with key # @return [String] A Base64 encoded signature of #signable_string with key
def sign_with_key(key) def sign_with_key(key)
sig = Base64.encode64(key.sign "SHA", signable_string) sig = Base64.encode64s(key.sign "SHA", signable_string)
log_hash = {:event => :sign_with_key, :status => :complete} log_hash = {:event => :sign_with_key, :status => :complete}
log_hash.merge(:model_id => self.id) if self.respond_to?(:persisted?) log_hash.merge(:model_id => self.id) if self.respond_to?(:persisted?)
Rails.logger.info(log_hash) Rails.logger.info(log_hash)

View file

@ -9,14 +9,14 @@ module Encryptor
ciphertext = aes_encrypt(cleartext, aes_key) ciphertext = aes_encrypt(cleartext, aes_key)
encrypted_key = encrypt_aes_key aes_key encrypted_key = encrypt_aes_key aes_key
cipher_hash = {:aes_key => encrypted_key, :ciphertext => ciphertext} cipher_hash = {:aes_key => encrypted_key, :ciphertext => ciphertext}
Base64.encode64( cipher_hash.to_json ) Base64.encode64s( cipher_hash.to_json )
end end
def gen_aes_key def gen_aes_key
cipher = OpenSSL::Cipher.new('AES-256-CBC') cipher = OpenSSL::Cipher.new('AES-256-CBC')
key = cipher.random_key key = cipher.random_key
iv = cipher.random_iv iv = cipher.random_iv
{'key' => Base64.encode64(key), 'iv' => Base64.encode64(iv)} {'key' => Base64.encode64s(key), 'iv' => Base64.encode64(iv)}
end end
def aes_encrypt(txt, key) def aes_encrypt(txt, key)
@ -27,11 +27,11 @@ module Encryptor
ciphertext = '' ciphertext = ''
ciphertext << cipher.update(txt) ciphertext << cipher.update(txt)
ciphertext << cipher.final ciphertext << cipher.final
Base64.encode64 ciphertext Base64.encode64s(ciphertext)
end end
def encrypt_aes_key key def encrypt_aes_key key
Base64.encode64 public_key.public_encrypt( key.to_json ) Base64.encode64s(public_key.public_encrypt( key.to_json ))
end end
end end

View file

@ -152,7 +152,7 @@ class Postzord::Dispatcher
# @param remote_people [Array<Person>] Recipients of the post on other pods # @param remote_people [Array<Person>] Recipients of the post on other pods
# @return [void] # @return [void]
def queue_remote_delivery_job(remote_people) def queue_remote_delivery_job(remote_people)
Resque.enqueue(Jobs::HttpMulti, @sender.id, Base64.encode64(@object.to_diaspora_xml), remote_people.map{|p| p.id}, self.class.to_s) Resque.enqueue(Jobs::HttpMulti, @sender.id, Base64.encode64s(@object.to_diaspora_xml), remote_people.map{|p| p.id}, self.class.to_s)
end end
end end

View file

@ -17,6 +17,7 @@ module Base64
# ArgumentError is raised if +str+ is incorrectly padded or contains # ArgumentError is raised if +str+ is incorrectly padded or contains
# non-alphabet characters. Note that CR or LF are also rejected. # non-alphabet characters. Note that CR or LF are also rejected.
def strict_decode64(str) def strict_decode64(str)
Rails.logger.info("trying to decode string: " + str)
str.unpack("m0").first str.unpack("m0").first
end end