KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
i need to do encryption and decryption in my rails app. Im trying to use ezcrypto, but whenever i do decryption i get this error. OpenSSL::Cipher::CipherError in ProfilesController#show wrong final block length What would need to be changed to stop this error. I tried using another implementation of openssl like this (methods to be called from my model) def encrypt_attr(unencrypted) c = OpenSSL::Cipher.new("aes-256-cbc") c.encrypt c.key = Digest::SHA1.hexdigest('pass') e = c.update(unencrypted) e << c.final return e end def decrypt_attr(encrypted_attr) if encrypted_attr != "" c = OpenSSL::Cipher::Cipher.new("aes-256-cbc") c.decrypt c.key = Digest::SHA1.hexdigest('pass') d = c.update(encrypted_attr) d << c.final return d end end It throws the exact same error on decryption. How should i do encryption and decryption and not get this openssl error.
Tags (comma-separated)
Save Edits
Cancel