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>