次の属性を持つ***ユーザーモデル***のアクティブレコードの暗号化にhttps://github.com/attr-encrypted/attr_encryptedを使用しています。
activation_hash 文字列 詳細文字列 メール文字列 IMEIストリング パスワード文字列 registration_id 文字列 secure_hash 文字列
これらの属性を次のように使用しました
attr_encrypted_options.merge!(:prefix => 'android_', :suffix => '_sheild')
attr_encrypted :activation_hash, :key => Getter::encryption_key, :encode => true
attr_encrypted :active, :key => Getter::encryption_key, :encode => true
attr_encrypted :code, :key => Getter::encryption_key, :encode => true
attr_encrypted :details, :key => Getter::encryption_key, :encode => true
attr_encryptor :email, :key => "this is awais"
attr_encrypted :password, :key => Getter::encryption_key, :encode => true
attr_encrypted :registration_id, :key => Getter::encryption_key, :encode => true
attr_encrypted :secure_hash, :key => Getter::encryption_key, :encode => true
attr_encrypted :imei, :key => Getter::encryption_key, :encode => true
attr_encrypted wiki で述べたように、データベースに保存されているレコードの空の文字列を保存すると。
Getter では、一般的な暗号化キー メソッドを追加しました。
module Getter
def self.encryption_key
keys = OpenSSL::Cipher::Cipher.new('aes-256-cbc').random_iv
return keys
end
end
ユーザーモデルに追加した暗号化された属性を使用して移行を追加する必要がありますか..アクティブレコードデータを暗号化し、そのフィールドをデータベースに保存することを目的としています。取得すると、復号化されたレコードを取得できますが、DBレベルではこれらのレコードにアクセスできません.
私が間違っていることを教えてください?? gemを切り替える必要がありますか??
あなたの提案は高く評価されています