Skip to content

Commit bbbcb1f

Browse files
committed
minor performance improvement
1 parent 282b806 commit bbbcb1f

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

apps/openhaystack/custom.html

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,7 @@
3535
A framework for tracking personal Bluetooth devices via Apple's massive Find My network
3636
https://github.com/seemoo-lab/openhaystack/issues/59#issuecomment-1303236903
3737
*/
38-
const key_b64 = ${JSON.stringify(keyValue)};
39-
40-
function b64ToArray(str) {
41-
let bstr = atob(str);
42-
let arr = [];
43-
for (let i = 0; i < bstr.length; i++) {
44-
arr[i] = bstr.charCodeAt(i);
45-
}
46-
return arr;
47-
}
48-
49-
const key = b64ToArray(key_b64); // public key
38+
const key = E.toUint8Array(atob(${JSON.stringify(keyValue)})); // public key
5039
const mac = [ key[0] | 0b11000000, key[1], key[2], key[3], key[4], key[5] ].map(x => x.toString(16).padStart(2, '0')).join(':'); // mac address
5140
const adv = [ 0x1e, 0xff, 0x4c, 0x00, 0x12, 0x19, 0x00, key[6], key[7], key[8], key[9], key[10], key[11], key[12], key[13], key[14], key[15], key[16], key[17], key[18], key[19], key[20], key[21], key[22], key[23], key[24], key[25], key[26], key[27], key[0] >> 6, 0x00 ]; // advertising packet
5241
NRF.setAddress(mac);

0 commit comments

Comments
 (0)