Can the signature be covered - Follow Up Deployment
Browse files- index.html +24 -17
index.html
CHANGED
|
@@ -498,17 +498,26 @@
|
|
| 498 |
updateCharCount();
|
| 499 |
}
|
| 500 |
|
| 501 |
-
// Generate a
|
| 502 |
function generateSignature() {
|
| 503 |
-
const
|
| 504 |
-
|
| 505 |
-
|
| 506 |
-
content: editor.getValue(),
|
| 507 |
-
timestamp: new Date().toISOString()
|
| 508 |
-
};
|
| 509 |
|
| 510 |
-
//
|
| 511 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 512 |
}
|
| 513 |
|
| 514 |
// Verify assignment (teacher mode)
|
|
@@ -550,15 +559,13 @@
|
|
| 550 |
|
| 551 |
// Generate verification signature
|
| 552 |
function generateVerificationSignature(assignmentData) {
|
| 553 |
-
|
| 554 |
-
const
|
| 555 |
-
|
| 556 |
-
studentName: assignmentData.studentName,
|
| 557 |
-
content: assignmentData.content,
|
| 558 |
-
timestamp: assignmentData.timestamp
|
| 559 |
-
};
|
| 560 |
|
| 561 |
-
|
|
|
|
|
|
|
| 562 |
}
|
| 563 |
|
| 564 |
// Show verification result
|
|
|
|
| 498 |
updateCharCount();
|
| 499 |
}
|
| 500 |
|
| 501 |
+
// Generate a secure signature for the assignment
|
| 502 |
function generateSignature() {
|
| 503 |
+
const secretSalt = "EDU_SECURE_" + Math.floor(Date.now() / 1000 / 3600); // Changes hourly
|
| 504 |
+
const contentHash = hashCode(editor.getValue());
|
| 505 |
+
const studentHash = hashCode(displayRollNumber.textContent + displayStudentName.textContent);
|
|
|
|
|
|
|
|
|
|
| 506 |
|
| 507 |
+
// Combine with timestamp and hash everything
|
| 508 |
+
const combined = `${secretSalt}|${contentHash}|${studentHash}|${new Date().toISOString()}`;
|
| 509 |
+
return hashCode(combined).toString(16).slice(0, 32);
|
| 510 |
+
}
|
| 511 |
+
|
| 512 |
+
// Helper function to create simple hash
|
| 513 |
+
function hashCode(str) {
|
| 514 |
+
let hash = 0;
|
| 515 |
+
for (let i = 0; i < str.length; i++) {
|
| 516 |
+
const char = str.charCodeAt(i);
|
| 517 |
+
hash = ((hash << 5) - hash) + char;
|
| 518 |
+
hash |= 0; // Convert to 32bit integer
|
| 519 |
+
}
|
| 520 |
+
return hash;
|
| 521 |
}
|
| 522 |
|
| 523 |
// Verify assignment (teacher mode)
|
|
|
|
| 559 |
|
| 560 |
// Generate verification signature
|
| 561 |
function generateVerificationSignature(assignmentData) {
|
| 562 |
+
const secretSalt = "EDU_SECURE_" + Math.floor(new Date(assignmentData.timestamp).getTime() / 1000 / 3600);
|
| 563 |
+
const contentHash = hashCode(assignmentData.content);
|
| 564 |
+
const studentHash = hashCode(assignmentData.rollNumber + assignmentData.studentName);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 565 |
|
| 566 |
+
// Combine with timestamp and hash everything
|
| 567 |
+
const combined = `${secretSalt}|${contentHash}|${studentHash}|${assignmentData.timestamp}`;
|
| 568 |
+
return hashCode(combined).toString(16).slice(0, 32);
|
| 569 |
}
|
| 570 |
|
| 571 |
// Show verification result
|