Class: EncryptedStore::ActiveRecord::EncryptionKeySalt
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- EncryptedStore::ActiveRecord::EncryptionKeySalt
- Defined in:
- lib/encrypted_store/active_record/encryption_key_salt.rb
Class Method Summary collapse
Class Method Details
.generate_salt(encryption_key_id) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/encrypted_store/active_record/encryption_key_salt.rb', line 9 def generate_salt(encryption_key_id) loop do salt = SecureRandom.random_bytes(16) begin salt_record = self.new salt_record.encryption_key_id = encryption_key_id salt_record.salt = salt salt_record.save! return salt rescue ::ActiveRecord::RecordNotUnique => e next end end end |