Class: Hello::Encryptors::Simple

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/hello/encryptors/simple.rb

Direct Known Subclasses

Complex

Instance Method Summary collapse

Instance Method Details

#encrypt(s) ⇒ Object



18
19
20
# File 'lib/hello/encryptors/simple.rb', line 18

def encrypt(s)
  Digest::MD5.hexdigest(s)
end

#match(string, token) ⇒ Object



22
23
24
# File 'lib/hello/encryptors/simple.rb', line 22

def match(string, token)
  encrypt(string) == token
end

#pair(complexity = 8) ⇒ Object



13
14
15
16
# File 'lib/hello/encryptors/simple.rb', line 13

def pair(complexity = 8)
  s = single(complexity)
  [s, encrypt(s)]
end

#single(complexity = 8) ⇒ Object

probability = 1 / ((8*2) ** (8*2))



9
10
11
# File 'lib/hello/encryptors/simple.rb', line 9

def single(complexity = 8)
  SecureRandom.hex(complexity)
end