lib/gibberish/aes.rb in gibberish-1.0.1 vs lib/gibberish/aes.rb in gibberish-1.0.2
- old
+ new
@@ -40,20 +40,16 @@
def encrypt(data, opts={})
salt = generate_salt
setup_cipher(:encrypt, salt)
e = cipher.update(data) + cipher.final
e = "Salted__#{salt}#{e}" #OpenSSL compatible
- if opts[:binary]
- e
- else
- Base64.encode64(e)
- end
+ opts[:binary] ? e : Base64.encode64(e)
end
alias :enc :encrypt
alias :e :encrypt
def decrypt(data, opts={})
- data = Base64.decode64(data)
+ data = Base64.decode64(data) unless opts[:binary]
salt = data[8..15]
data = data[16..-1]
setup_cipher(:decrypt, salt)
cipher.update(data) + cipher.final
end