lib/ezcrypto.rb in ezcrypto-0.3 vs lib/ezcrypto.rb in ezcrypto-0.5
- old
+ new
@@ -159,11 +159,11 @@
=begin rdoc
returns the Base64 encoded key.
=end
def encode
- Base64.encode64 @raw
+ Base64.encode64(@raw).chop
end
=begin rdoc
returns the Base64 encoded key. Synonym for encode.
=end
@@ -198,23 +198,40 @@
nil
else
decrypter("")
@cipher.gulp(data)
end
- rescue
- puts @algorithm
- throw $!
+# rescue
+# puts @algorithm
+# puts self.encode
+# puts data.size
+# throw $!
end
=begin rdoc
Decrypts a Base64 formatted string
=end
def decrypt64(data)
decrypt(Base64.decode64(data))
end
+
+=begin rdoc
+Allows keys to be marshalled
+=end
+ def marshal_dump
+ "#{self.algorithm}$$$#{self.encode}"
+ end
+
+=begin rdoc
+Allows keys to be unmarshalled
+=end
+ def marshal_load(s)
+ a, r = s.split '$$$'
+ @algorithm = a
+ @raw = Base64.decode64(r)
+ end
-
=begin rdoc
Create a file with minimal permissions, and yield
it to a block. By default only the owner may read it.
=end
def safe_create(file, mod=0400, mask=0066)
@@ -457,9 +474,11 @@
Processes the entire data string using update and performs a final on it returning the data.
=end
def gulp(data)
update(data)
final
+# rescue
+# breakpoint
end
=begin rdoc
=end