Class: Hubtime::HubConfig::Stuff

Inherits:
Object
  • Object
show all
Defined in:
lib/hubtime/hub_config.rb

Class Method Summary collapse

Class Method Details

.decrypt(encrypted) ⇒ Object



111
112
113
114
115
116
117
118
119
# File 'lib/hubtime/hub_config.rb', line 111

def self.decrypt(encrypted)
  return nil if encrypted == nil

  aes = OpenSSL::Cipher.new("AES-256-CFB")
  aes.decrypt
  aes.key = key
  aes.iv = iv
  aes.update(encrypted) + aes.final
end

.encrypt(payload) ⇒ Object



101
102
103
104
105
106
107
108
109
# File 'lib/hubtime/hub_config.rb', line 101

def self.encrypt(payload)
  return nil if payload == nil
  aes = OpenSSL::Cipher.new("AES-256-CFB")
  aes.encrypt
  aes.key = key
  aes.iv = iv

  aes.update(payload) + aes.final
end

.ivObject



98
99
100
# File 'lib/hubtime/hub_config.rb', line 98

def self.iv
  "kjfdhkkkjkjhfdskljghfkdjhags"
end

.keyObject



94
95
96
97
# File 'lib/hubtime/hub_config.rb', line 94

def self.key
  sha256 = Digest::SHA2.new(256)
  sha256.digest("better than plain text")
end