11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/bluepay/tamper_proof_seal.rb', line 11
def hash(type, *args)
_args = args.insert(0, Bluepay.account_id).map(&:to_s).join
case type
when HMAC_SHA512, nil
OpenSSL::HMAC.hexdigest('sha512', Bluepay.secret_key, _args)
when HMAC_SHA256
OpenSSL::HMAC.hexdigest('sha256', Bluepay.secret_key, _args)
when SHA512
Digest::SHA512.hexdigest([
Bluepay.secret_key,
_args,
type
].join)
when SHA256
then Digest::SHA256.hexdigest([
Bluepay.secret_key,
_args,
type
].join)
when MD5
Digest::MD5.hexdigest([
Bluepay.secret_key,
_args,
type
].join)
else
raise "Please set Bluepay.hash=."
end
end
|