我正在尝试User
在 Ruby on Rails 中加密我的模型上的两列。我已经成功加密了另一个表上的 6 个其他列,但这次我must specify an iv
只在User
表上得到错误。
我正在使用设计 gem 进行身份验证。
这是我添加列的原始迁移:
class AddPushNotificationColumnsToUser < ActiveRecord::Migration[5.1]
def change
add_column :users, :endpoint, :string
add_column :users, :expiration_time, :string
add_column :users, :encrypted_p256dh, :string
add_column :users, :encrypted_auth, :string
add_column :users, :encrypted_p256dh_iv, :string
add_column :users, :encrypted_auth_iv, :string
end
end
我的模型:
attr_encrypted :p256dh, key: Rails.application.secrets.db_encryption_key
attr_encrypted :auth, key: Rails.application.secrets.db_encryption_key
当我打电话User.first.p256dh
或User.first.auth
收到错误消息时:must specify an iv
任何帮助,将不胜感激。