Sha256: 5822fa7ff85610f9506c6314401db7274779d8ea95c5b815ec9cfe524ca77339

Contents?: true

Size: 498 Bytes

Versions: 3

Compression:

Stored size: 498 Bytes

Contents

require 'crypt/blowfish'

class Encrypter
  def self.encrypt(input)
    return nil unless input.is_a?(String)
    Base64.encode64(self.blowfish.encrypt_string(input))
  end

  def self.decrypt(input)
    return nil unless input.is_a?(String)
    self.blowfish.decrypt_string(Base64.decode64(input))
  end

  def self.salt
    @@salt || 'common-salt'
  end

  def self.salt=(value)
    @@salt = value
  end

  private

  def self.blowfish
    @@blowfish ||= Crypt::Blowfish.new(self.salt)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
commonthread-rails-0.4.2 lib/commonthread/encrypter.rb
commonthread-rails-0.4.1 lib/commonthread/encrypter.rb
commonthread-rails-0.4.0 lib/commonthread/encrypter.rb