Module: Opensteam::Security::Encryption

Defined in:
lib/opensteam/security.rb

Instance Method Summary collapse

Instance Method Details

#decrypt(encrypted_data, password, salt) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/opensteam/security.rb', line 41

def decrypt( encrypted_data, password, salt )
  cipher = OpenSSL::Cipher::Cipher.new( algorithm )
  cipher.decrypt
  cipher.pkcs5_keyivgen( password, salt )
  data = cipher.update( encrypted_data )
  data << cipher.final
end

#encrypt(data, password, salt) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/opensteam/security.rb', line 32

def encrypt( data, password, salt )
  cipher = OpenSSL::Cipher::Cipher.new algorithm
  cipher.encrypt
  cipher.pkcs5_keyivgen( password, salt )
  encrypted_data = cipher.update( data )
  encrypted_data << cipher.final
end