forked from bgli100/Blackbox-QRCode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
53 lines (52 loc) · 1.93 KB
/
index.html
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
<!DOCTYPE html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.0.0/crypto-js.min.js"></script>
<script src="./js/qrcodegen.js"></script>
</head>
<body style="text-align: center;">
<h2>QRCode for Today</h2>
<canvas id="blue-today"></canvas>
<canvas id="green-today"></canvas>
<canvas id="pink-today"></canvas>
<br />
<h2>QRCode for Yesterday</h2>
Game may complain "old" or "fishy" for timing issue, so I added more codes for you to try here
<br />
<canvas id="blue-yesterday"></canvas>
<canvas id="green-yesterday"></canvas>
<canvas id="pink-yesterday"></canvas>
<br />
<h2>QRCode for Tomorrow</h2>
and here.
<br />
<canvas id="blue-tomorrow"></canvas>
<canvas id="green-tomorrow"></canvas>
<canvas id="pink-tomorrow"></canvas>
<script>
let p1 = ["💠", "❇️", "💟"];
let color = ["blue", "green", "pink"];
let fgColor = ["#586fd9", "#5BCAAD", "#C54984"];
let dateOffset = ["yesterday", "today", "tomorrow"];
let julianDayNumber = Math.floor(2440588 + Date.now() / 86400000);
color.forEach((v, i) => {
dateOffset.forEach((dv, di) => {
let p2 = (julianDayNumber + di - 1).toString();
let hash = CryptoJS.HmacSHA256(p1[i] + p2, 'blackbox');
let str = hash.toString(CryptoJS.enc.Hex).substring(0, 5);
let qrStr = p1[i] + "✨" + str;
console.log(qrStr);
let qr = qrcodegen.QrCode.encodeSegments(
qrcodegen.QrSegment.makeSegments(qrStr),
qrcodegen.QrCode.Ecc.HIGH,
2, 2, 5, false
);
qr.drawCanvas(
8, 4,
document.getElementById(v + "-" + dv),
fgColor[i],
"#FFFFFF"
);
});
});
</script>
</body>