This repository has been archived by the owner on May 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
71 lines (63 loc) · 1.6 KB
/
index.js
1
2
3
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
'use strict';
var crypto = require('crypto');
exports.createSignature = function (params, key) {
var united = params.wsb_seed
+ params.wsb_storeid
+ params.wsb_order_num
+ params.wsb_test
+ params.wsb_currency_id
+ params.wsb_total
+ key;
switch (parseInt(params.wsb_version)) {
case 1:
console.log('md5');
return crypto.createHash('md5').update(united).digest('hex');
break;
case 2:
console.log('sha1');
return crypto.createHash('sha1').update(united).digest('hex');
break;
default:
return '';
}
};
exports.checkSignature = function (params, key) {
if (!params.wsb_signature) return false;
var united = params.batch_timestamp
+ params.currency_id
+ params.amount
+ params.payment_method
+ params.order_id
+ params.site_order_id
+ params.transaction_id
+ params.payment_type
+ params.rrn
+ key;
if (params.wsb_signature == crypto.createHash('md5').update(united).digest('hex')) {
return true;
} else {
return false;
}
};
exports.createSignatureHalva = function (params, key) {
var united = params.wsb_seed
+ params.wsb_storeid
+ params.wsb_order_num
+ params.wsb_test
+ params.wsb_currency_id
+ params.wsb_total
+ params.wsb_terminal_halva
+ key;
switch (parseInt(params.wsb_version)) {
case 1:
console.log('md5');
return crypto.createHash('md5').update(united).digest('hex');
break;
case 2:
console.log('sha1');
return crypto.createHash('sha1').update(united).digest('hex');
break;
default:
return '';
}
};