Class: QuoVadis::Crypt
- Inherits:
-
Object
- Object
- QuoVadis::Crypt
- Defined in:
- lib/quo_vadis/crypt.rb
Class Method Summary collapse
Class Method Details
.decrypt(value) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/quo_vadis/crypt.rb', line 16 def self.decrypt(value) return nil if value.nil? return '' if value == '' salt, data = value.split SEPARATOR crypt = encryptor salt crypt.decrypt_and_verify(data) end |
.encrypt(value) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/quo_vadis/crypt.rb', line 6 def self.encrypt(value) return nil if value.nil? return '' if value == '' salt = SecureRandom.hex KEY_LENGTH crypt = encryptor salt ciphertext = crypt.encrypt_and_sign value [salt, ciphertext].join SEPARATOR end |