0

Am using AESCrypt for encrypt and Decrypt the Email address stored in the db. Encryption is working. But during Decryption wrong final block length error was occur.

Error

OpenSSL::Cipher::CipherError in DashboardUsersController#index

In User model:

after_validation(on: :create) do
    self.email= AESCrypt.encrypt(email, "password")
end

In UsersController:

   if @users != nil then
      @users.each do |usr|
        usrEmail = usr.email
       usr.email = AESCrypt.decrypt(usrEmail, "password")
      end
    end 

In user_view.html.rb

<th>Email id</th>
<td><%= user.email %></td>
Rubyrider
  • 3,567
  • 1
  • 28
  • 34
Raj
  • 950
  • 1
  • 9
  • 33

0 Answers0