Class: Utilio::Security

Inherits:
Object
  • Object
show all
Defined in:
lib/utilio/security.rb

Class Method Summary collapse

Class Method Details

.decrypt(string, kw = {}) ⇒ Object



25
26
27
28
29
30
# File 'lib/utilio/security.rb', line 25

def decrypt string, kw = {}
  c = cipher
  c.decrypt
  c.key = key
  c.update(Base64.decode64("#{ string }\n")) + c.final
end

.encrypt(string) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/utilio/security.rb', line 16

def encrypt string
  c = cipher
  c.encrypt
  c.key = key

  e = c.update(string) + c.final
  Base64.encode64(e).chop
end

.hash_string(value) ⇒ Object



8
9
10
# File 'lib/utilio/security.rb', line 8

def hash_string(value)
  Security.secure_digest( value )
end

.secure_digest(*args) ⇒ Object



12
13
14
# File 'lib/utilio/security.rb', line 12

def secure_digest(*args)
  Digest::SHA2.hexdigest(args.flatten.join('--'))
end