· 7 years ago · Mar 31, 2018, 11:46 PM
1unction encrypt_v1_beacon() {
2 var sample_key = new Buffer('AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8=', "Base64");
3 console.log('key b64: ' + sample_key);
4
5 var secret_key = sample_key.toString();
6 //the require should point to where hashlib is
7 const crypto = require("crypto");
8 var m = crypto.createHmac("md5",secret_key);
9 console.log('secret_key md5: ' + m.digest("hex"));
10
11 var sample_strings = ['abcd',
12 'a=21&p=erpgtijergoptkm&i=1.2.3.4&t=1242340548954',
13 'a=21&p=dghpokerggpijerg&s=UNIFIED_LOGIN'];
14
15 var signed_strings = [];
16 sample_strings.forEach(function(item,index,array) {
17 var tuple = [item, crypto.createHmac('sha1',secret_key)];
18 signed_strings.push(tuple);
19 });
20
21 signed_strings.forEach(function(item,index,array) {
22 var plain = item[0];
23 var sig = item[1].toString();
24 var r = plain + sig;
25 console.log(r);
26 });
27
28}
29
30encrypt_v1_beacon()