mirror of
https://github.com/cliffe/BreakEscape.git
synced 2026-02-21 11:18:08 +00:00
feat(rfid): Enhance hex generation with improved hash-based approach for realistic card data
This commit is contained in:
126
test-rfid-hex-generation.html
Normal file
126
test-rfid-hex-generation.html
Normal file
@@ -0,0 +1,126 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>RFID Hex Generation Test</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: 'VT323', 'Courier New', monospace;
|
||||
background: #222;
|
||||
color: #fff;
|
||||
padding: 20px;
|
||||
}
|
||||
.container {
|
||||
max-width: 600px;
|
||||
margin: 0 auto;
|
||||
background: #333;
|
||||
padding: 20px;
|
||||
border: 2px solid #666;
|
||||
}
|
||||
h1 {
|
||||
color: #FF8200;
|
||||
margin-top: 0;
|
||||
}
|
||||
.card {
|
||||
background: #444;
|
||||
border: 2px solid #666;
|
||||
padding: 15px;
|
||||
margin: 15px 0;
|
||||
}
|
||||
.card-field {
|
||||
display: grid;
|
||||
grid-template-columns: 150px 1fr;
|
||||
gap: 20px;
|
||||
margin: 8px 0;
|
||||
font-size: 14px;
|
||||
}
|
||||
.card-field strong {
|
||||
color: #FFA500;
|
||||
}
|
||||
.card-field span {
|
||||
color: #0F0;
|
||||
font-weight: bold;
|
||||
}
|
||||
.info {
|
||||
background: #2a2a2a;
|
||||
border-left: 4px solid #FF8200;
|
||||
padding: 10px;
|
||||
margin: 20px 0;
|
||||
font-size: 12px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>🔐 RFID Hex Generation Test</h1>
|
||||
<p>Testing realistic RFID card data generation from card_id</p>
|
||||
|
||||
<div id="test-results"></div>
|
||||
</div>
|
||||
|
||||
<script type="module">
|
||||
// Import the data manager
|
||||
import { RFIDDataManager } from './js/minigames/rfid/rfid-data.js';
|
||||
|
||||
const dataManager = new RFIDDataManager();
|
||||
const testCardIds = [
|
||||
'employee_badge',
|
||||
'hotel_keycard',
|
||||
'corporate_badge',
|
||||
'executive_card',
|
||||
'master_override',
|
||||
'master_keycard',
|
||||
'ceo_keycard'
|
||||
];
|
||||
|
||||
const resultsDiv = document.getElementById('test-results');
|
||||
|
||||
// Generate and display data for each card_id
|
||||
testCardIds.forEach(cardId => {
|
||||
const rfidData = dataManager.generateRFIDDataFromCardId(cardId, 'EM4100');
|
||||
|
||||
const card = document.createElement('div');
|
||||
card.className = 'card';
|
||||
|
||||
card.innerHTML = `
|
||||
<div class="card-field">
|
||||
<strong>Card ID:</strong>
|
||||
<span>${cardId}</span>
|
||||
</div>
|
||||
<div class="card-field">
|
||||
<strong>HEX:</strong>
|
||||
<span>${rfidData.hex}</span>
|
||||
</div>
|
||||
<div class="card-field">
|
||||
<strong>Facility:</strong>
|
||||
<span>${rfidData.facility}</span>
|
||||
</div>
|
||||
<div class="card-field">
|
||||
<strong>Card Number:</strong>
|
||||
<span>${rfidData.cardNumber}</span>
|
||||
</div>
|
||||
<div class="card-field">
|
||||
<strong>DEZ 8:</strong>
|
||||
<span>${String(rfidData.cardNumber).padStart(8, '0')}</span>
|
||||
</div>
|
||||
`;
|
||||
|
||||
resultsDiv.appendChild(card);
|
||||
});
|
||||
|
||||
// Info message
|
||||
const info = document.createElement('div');
|
||||
info.className = 'info';
|
||||
info.innerHTML = `
|
||||
<strong>✓ Improvements:</strong><br>
|
||||
• Hex values are now deterministic but realistic (no all-zeros)<br>
|
||||
• Each card_id always produces the same hex (reproducible)<br>
|
||||
• Facility codes range from 0-255<br>
|
||||
• Card numbers are properly distributed<br>
|
||||
• Different card_ids produce visually distinct hex values
|
||||
`;
|
||||
resultsDiv.appendChild(info);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user