diff --git a/client/public/code-book-print.html b/client/public/code-book-print.html
index aa45674..31a9062 100644
--- a/client/public/code-book-print.html
+++ b/client/public/code-book-print.html
@@ -127,11 +127,11 @@
-
Encryption Key
+
Encryption Key
-
ASCII Reference Table
+
ASCII REFERENCE TABLE
@@ -162,12 +162,13 @@
}
function renderASCIITable() {
- let html = '';
- html += '| Dec | Hex | Char | Dec | Hex | Char | Dec | Hex | Char | Dec | Hex | Char |
';
+ let html = '';
- for (let row = 0; row < 32; row++) {
- html += '
';
- for (let col = 0; col < 4; col++) {
+ for (let col = 0; col < 4; col++) {
+ html += '';
+ html += '| Char | Hex | Dec |
';
+
+ for (let row = 0; row < 32; row++) {
const code = row + (col * 32);
if (code < 128) {
const hex = code.toString(16).toUpperCase().padStart(2, '0');
@@ -183,26 +184,36 @@
char = 'DEL';
}
- html += `${code} | ${hex} | ${char} | `;
+ html += `| ${char} | ${hex} | ${code} |
`;
}
}
- html += '';
+
+ html += '
';
}
- html += '
';
+ html += '';
document.getElementById('ascii-print').innerHTML = html;
}
function renderOTPPairs(key) {
- const columns = [[], [], [], [], []];
-
+ const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
+ const pairs = [];
+ const used = new Set();
for (let i = 0; i < 250; i++) {
- const nonce = i.toString().padStart(3, '0');
- const code = generateHOTP(key, nonce);
- const pair = `${nonce} ${code}`;
- columns[Math.floor(i / 50)].push(pair);
- }
+ let nonce;
+ do {
+ nonce = chars[Math.floor(Math.random() * chars.length)] + chars[Math.floor(Math.random() * chars.length)];
+ } while (used.has(nonce));
+ used.add(nonce);
+ const code = generateHOTP(key, nonce);
+ pairs.push(`${nonce} ${code}`);
+ }
+ pairs.sort();
+ const columns = [[], [], [], [], []];
+ for (let i = 0; i < pairs.length; i++) {
+ columns[Math.floor(i / 50)].push(pairs[i]);
+ }
let html = '';
for (let col of columns) {
html += '';
@@ -211,7 +222,6 @@
}
html += '
';
}
-
document.getElementById('otp-grid').innerHTML = html;
}
@@ -219,10 +229,8 @@
let html = '';
const rows = 'NOPQRSTUVWXYZ'.split('');
const cols = 'ABCDEFGHIJKLM'.split('');
-
for (let tableIndex = 0; tableIndex < 26; tableIndex++) {
const table = generateAuthTable(key, tableIndex);
-
html += '';
html += `
${PHONETIC[tableIndex]}
`;
html += '
';
@@ -231,7 +239,6 @@
html += `| ${col} | `;
}
html += '';
-
for (let i = 0; i < rows.length; i++) {
html += `| ${rows[i]} | `;
for (let j = 0; j < cols.length; j++) {
@@ -242,23 +249,19 @@
html += '
|---|
';
html += '
';
}
-
document.getElementById('auth-tables').innerHTML = html;
}
function renderPadKeys(key) {
let html = '';
-
- for (let i = 0; i < 50; i++) {
+ for (let i = 0; i < 100; i++) {
const padKey = (i * 1000).toString().padStart(5, '0');
const cipher = generatePadDisplay(key, padKey);
-
html += '';
html += `
Key: ${padKey}
`;
html += `
${cipher}
`;
html += '
';
}
-
document.getElementById('pad-list').innerHTML = html;
}
@@ -273,11 +276,7 @@
renderOTPPairs(key);
renderAuthTables(key);
renderPadKeys(key);
-
- // Auto-print after everything loads
- setTimeout(() => {
- window.print();
- }, 500);
+ setTimeout(() => {window.print();}, 500);
}