How to resolve deprecation warnings for OpenSSL::Cipher::Cipher#encrypt
Posted
by Olly
on Stack Overflow
See other posts from Stack Overflow
or by Olly
Published on 2009-08-28T21:13:24Z
Indexed on
2010/04/03
2:13 UTC
Read the original article
Hit count: 528
I've just upgraded my Mac to Snow Leopard and got my Rails environment up and running. The only difference -- OSX aside -- with my previous install is that I'm now running ruby 1.8.7 (2008-08-11 patchlevel 72) [universal-darwin10.0]
(Snow Leopard default) rather than 1.8.6.
I'm now seeing deprecation warnings relating to OpenSSL when I run my code:
warning: argumtents for OpenSSL::Cipher::Cipher#encrypt and OpenSSL::Cipher::Cipher#decrypt were deprecated; use OpenSSL::Cipher::Cipher#pkcs5_keyivgen to derive key and IV
Example of my code which is causing these warnings (it decodes an encrypted string) on line 4:
1. def decrypt(data)
2. encryptor = OpenSSL::Cipher::Cipher.new('DES-EDE3-CBC')
3. key = "my key"
4. encryptor.decrypt(key)
5. text = encryptor.update(data)
6. text << encryptor.final
7. end
I'm struggling to understand how I can resolve this, and Google isn't really helping. Should I try and downgrade to Ruby 1.8.6 (and if so, what's the best way of doing this?), should I try and just hide the warnings (bury my head in the sand?!) or is there an easy fix I can apply in the code?
© Stack Overflow or respective owner