Permalink
Browse files

Merge pull request #2 from gucki/master

add support for the :binary option to AES#decrypt
  • Loading branch information...
2 parents 410a165 + 6ce0979 commit c40d6ee7e4a6e596d1645809ef5588dae2f0e0ae @mdp mdp committed May 12, 2011
Showing with 2 additions and 6 deletions.
  1. +2 −6 lib/gibberish/aes.rb
@@ -42,17 +42,13 @@ def encrypt(data, opts={})
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)

0 comments on commit c40d6ee

Please sign in to comment.