Questions tagged [attr-encrypted]
63 questions
15
votes
2 answers
Unique IVs producing identical ciphertext using attr_encrypted
Using the most basic setup:
class User < ActiveRecord::Base
attr_encrypted :name,
key: 'This is a key that is 256 bits!!',
encode: true,
encode_iv: true,
encode_salt:…

scoots
- 715
- 4
- 16
5
votes
3 answers
Using attr_encrypted with rails 7
We have upgraded our application to rails 7, and we are now having issues with the attr_encrypted gem. When we try start a rails server/console we get the following error:
gems/ruby-3.0.2/gems/attr_encrypted-3.1.0/lib/attr_encrypted.rb:176:in `block…

Brandon Teixeira
- 195
- 9
5
votes
1 answer
Querying in rails on attr_encrypted column
I have a ruby on rails app and I am using the attr_encrypted gem to encrypt some user info. It has a salt and IV so it is 2 way encrypted. The gem intercepts dynamic find_by to assist with querying, but that is not a sufficient query for my case as…

user3397380
- 51
- 3
5
votes
2 answers
How do you use fixtures with attr_encrypted
I want to test a model that uses attr_encrypted to encrypt a secret in the database
class Thing
attr_encrypted :secret, encode: true
end
But when I define the secret in a fixture the encoded newline character gets escaped out.
one:
…

ReggieB
- 8,100
- 3
- 38
- 46
5
votes
2 answers
How can I do wildcarded search on encrypted elements in database
I am using attr_encrypted to encrypt some of my model fields, and I use Tire with Elasticsearch for full text searching. I use just a simple search form.
here is part of my model:
class Student < ActiveRecord::Base
include Tire::Model::Search
…

user1679897
- 51
- 3
4
votes
1 answer
How to search an encrypted field in attr_encrypted
I have set up attr_encrypted in my app with individual 'iv's for every record.
# Fields
User.e_name
User.e_name_iv
I am trying to search the User table for a known name. I've tried:
User.find_by_name("Joe Bloggs") # undefined method "find_by_name"…

sscirrus
- 55,407
- 41
- 135
- 228
4
votes
2 answers
Redacting a SSN on form display under Rails 4?
I have a Rails 4 application and I am using the attr_encrypted gem to store SSN in an encrypted form in the DB.
What I am trying to do is only display the last 4 digits when editing / showing the form. So essentially once the SSN has been saved,…

James McMahon
- 48,506
- 64
- 207
- 283
4
votes
1 answer
RoR: attr_encrypted is not saving data on database
I'm using attr_encrypted in rails 3.2.13 to encrypt a column. For that, in my model I have the following:
attr_encrypted :social_security_no, :key => 'a secret key'
The app does not save neither social_security_no nor encrypted_social_security_no on…

Ashish Bista
- 4,533
- 1
- 18
- 25
3
votes
0 answers
Encrypting with attr-encrypt gem but can't decrypt
Using gem: https://github.com/attr-encrypted/attr_encrypted
Issue 1:
When I create the record and encrypt, I go to the console (via Heroku) and do:
model = Model.find(1)
model.attribute
Error: OpenSSL::Cipher::CipherError ()
Issue 2:
I create the…

uno
- 1,421
- 12
- 38
3
votes
1 answer
How to sort on a field that is encrypted using the attr_encrypted gem
I am currently using attr_encrypted gem to encrypt content so that only users that have a certain key can see portions of documents available to a broader group. Everything works fine until I try to sort the list on one of the encrypted fields. I've…

Jay
- 6,206
- 11
- 48
- 82
3
votes
2 answers
Where should the security keys for attr_encrypted be stored?
I have been looking at attr_encrypted, but it stores the keys in the code, which doesn't seem to be so secure. If my webserver gets breached, the encryption won't help much.
What are some options for which the data could still be secure if my…

Dofs
- 17,737
- 28
- 75
- 123
2
votes
0 answers
attr_encrypted gem sometimes saving null value in database
I am running rails 3 version and using attr_encrypted gem version '1.2.1' . sometimes i have seen that nil entry is getting stored into column encrypted_private_key.
Below is my model
class Device < ActiveRecord::Base
attr_encrypted :private_key,…

user2274074
- 991
- 2
- 9
- 25
2
votes
2 answers
attr_encrypted gem not working in rails 6
I was using attr_encrypted (1.3.3) in rails 4.1 in User model with following details
attr_encrypted :email, :key => 'some_key'
After upgrading the application to rails 6 attr_encrypted bumped to attr_encrypted (3.1.0) which uses encryptor (~>…

Bloomberg
- 2,317
- 2
- 25
- 47
2
votes
0 answers
Encrypt new data with new key using attr_encrypted (overriding old data)
I have to write a script that replace existing data with dummy (but valid) data. The script should only populate fields that are already populated on each record. I should NOT put dummy data into fields where no data existed previously. Can any one…

sharmila
- 31
- 4
2
votes
0 answers
How to encrypt new data with new key using attr_encrypted (over old data)?
I am using attr_encrypted, and have some data encrypted with a key that I no longer have access to. I would like to overwrite the existing/old data with new data, using a new key. How can I do this?
For example, consider this:
class User
…

user664833
- 18,397
- 19
- 91
- 140