I am using https://github.com/attr-encrypted/attr_encrypted for the encryptions of my active record for ***User model***who have following attributes.
activation_hash string details string email string imei string password string registration_id string secure_hash string
I used these attributes as
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
as mentioned in the attr_encrypted wiki but when i save the record empty string in stored in databases.
In Getter i have added the generic encryption key method..
module Getter
def self.encryption_key
keys = OpenSSL::Cipher::Cipher.new('aes-256-cbc').random_iv
return keys
end
end
Do i need to add migration with encrypted attributes i added in User model.. My aim to to encrypt the activerecord data and save that fields to databases and when i retrieve i can get decrypted record back but on DB level These records are not accessible.
Can you please tell me what i do wrong?? Do i need to switch gem??
Your suggestions are highly appreciated