wrong final block length in AESCrypt

578 views Asked by At

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>
0

There are 0 answers