4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/sorcery/crypto_providers/common.rb', line 4
def self.included(base)
base.class_eval do
class << self
attr_accessor :join_token
def stretches
@stretches ||= 1
end
attr_writer :stretches
def encrypt(*tokens)
digest = tokens.flatten.compact.join(join_token)
stretches.times { digest = secure_digest(digest) }
digest
end
def matches?(crypted, *tokens)
encrypt(*tokens.compact) == crypted
end
def reset!
@stretches = 1
@join_token = nil
end
end
end
end
|