-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreorder_keys.js
More file actions
76 lines (60 loc) · 2.68 KB
/
reorder_keys.js
File metadata and controls
76 lines (60 loc) · 2.68 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
const fs = require('fs');
const AdvancedKeyFinder = require('./key_finder');
async function reorderExistingFile() {
const targetFile = 'high_entropy_keys.txt';
console.log('🔄 ENTROPY-BASED FILE REORGANIZER');
console.log('═'.repeat(35));
console.log(`📁 Processing: ${targetFile}`);
if (!fs.existsSync(targetFile)) {
console.log('❌ Target file not found!');
return;
}
const finder = new AdvancedKeyFinder();
try {
// Read and parse existing content
const content = fs.readFileSync(targetFile, 'utf-8');
const entries = finder.parseExistingEntries(content);
console.log(`📊 Found ${entries.length} existing entries`);
if (entries.length === 0) {
console.log('💤 No valid entries found to reorder');
return;
}
// Calculate statistics before reordering
const entropies = entries.map(e => e.entropy);
const maxEntropy = Math.max(...entropies);
const minEntropy = Math.min(...entropies);
const avgEntropy = entropies.reduce((a, b) => a + b, 0) / entropies.length;
console.log('');
console.log('📈 ENTROPY ANALYSIS:');
console.log('─'.repeat(20));
console.log(`Highest: ${maxEntropy.toFixed(2)}`);
console.log(`Lowest: ${minEntropy.toFixed(2)}`);
console.log(`Average: ${avgEntropy.toFixed(2)}`);
// Create backup
const backupFile = `${targetFile}.backup.${Date.now()}`;
fs.copyFileSync(targetFile, backupFile);
console.log(`💾 Backup created: ${backupFile}`);
// Rebuild with proper sorting
await finder.rebuildTargetFile(entries);
console.log('');
console.log('✅ REORDERING COMPLETE!');
console.log('🎯 Highest entropy keys are now at the top');
console.log('📈 This optimizes wallet checking priority');
// Show top 5 entries
const sortedEntries = entries.sort((a, b) => b.entropy - a.entropy);
console.log('');
console.log('🔑 TOP 5 HIGHEST ENTROPY ENTRIES:');
console.log('─'.repeat(32));
sortedEntries.slice(0, 5).forEach((entry, index) => {
console.log(`${index + 1}. Entropy: ${entry.entropy.toFixed(2)} | Type: ${entry.type}`);
console.log(` Value: ${entry.value.substring(0, 50)}${entry.value.length > 50 ? '...' : ''}`);
});
} catch (error) {
console.error('❌ Error:', error.message);
}
}
// Run if called directly
if (require.main === module) {
reorderExistingFile();
}
module.exports = { reorderExistingFile };