RubyPulse Episode 0.26 - encryptor
A simple wrapper for the standard ruby OpenSSL library. - shuber
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'encryptor'
=> true
irb(main):003:0> str = "rubypulse"
=> "rubypulse"
irb(main):004:0> Encryptor.encrypt str, :key => "secret"
=> "F\277)\246\216i\247\372IA\352c\233\023\006\262"
irb(main):005:0> e_str = _
=> "F\277)\246\216i\247\372IA\352c\233\023\006\262"
irb(main):006:0> e_str
=> "F\277)\246\216i\247\372IA\352c\233\023\006\262"
irb(main):007:0> Encryptor.decrypt e_str, :key => "secret"
=> "rubypulse"
irb(main):008:0> Encryptor.default_options
=> {:algorithm=>"aes-256-cbc"}
irb(main):009:0> Encryptor.default_options.merge! :key => "secret"
=> {:key=>"secret", :algorithm=>"aes-256-cbc"}
irb(main):010:0> Encryptor.default_options
=> {:key=>"secret", :algorithm=>"aes-256-cbc"}
irb(main):011:0> Encryptor.decrypt e_str
=> "rubypulse"
irb(main):012:0> e_str.decrypt
=> "rubypulse"
irb(main):013:0> str.encrypt
=> "F\277)\246\216i\247\372IA\352c\233\023\006\262"
irb(main):014:0> e_str.decrypt!
=> "rubypulse"
irb(main):015:0> e_str
=> "rubypulse"
Links for this episode
| encryptor on Github |
| attr_encrypted on Github |
Tags : encryptor, openssl, encrypt, decrypt, attr_encrypted