Class: Encrypter

Inherits:
Object show all
Defined in:
lib/commonthread/encrypter.rb

Class Method Summary collapse

Class Method Details

.blowfishObject



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

.saltObject



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