Class: Encrypter
Class Method Summary collapse
- .blowfish ⇒ Object
- .decrypt(input) ⇒ Object
- .encrypt(input) ⇒ Object
- .salt ⇒ Object
- .salt=(value) ⇒ Object
Class Method Details
.blowfish ⇒ Object
22 23 24 |
# File 'lib/commonthread/encrypter.rb', line 22 def self.blowfish @@blowfish ||= Crypt::Blowfish.new(self.salt) end |
.decrypt(input) ⇒ Object
7 8 9 10 |
# File 'lib/commonthread/encrypter.rb', line 7 def self.decrypt(input) return nil unless input.is_a?(String) self.blowfish.decrypt_string(Base64.decode64(input)) end |
.encrypt(input) ⇒ Object
2 3 4 5 |
# File 'lib/commonthread/encrypter.rb', line 2 def self.encrypt(input) return nil unless input.is_a?(String) Base64.encode64(self.blowfish.encrypt_string(input)) end |
.salt ⇒ Object
12 13 14 |
# File 'lib/commonthread/encrypter.rb', line 12 def self.salt @@salt || 'common-salt' end |
.salt=(value) ⇒ Object
16 17 18 |
# File 'lib/commonthread/encrypter.rb', line 16 def self.salt=(value) @@salt = value end |