@@ -35,7 +35,6 @@ interface HashDocument {
|
||||
sha1: string;
|
||||
sha256: string;
|
||||
sha512: string;
|
||||
bcrypt: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
@@ -157,17 +156,13 @@ function deleteState(stateFile: string): void {
|
||||
}
|
||||
}
|
||||
|
||||
async function generateHashes(plaintext: string): Promise<HashDocument> {
|
||||
const bcrypt = await import('bcrypt');
|
||||
const bcryptHash = await bcrypt.default.hash(plaintext, 10);
|
||||
|
||||
function generateHashes(plaintext: string): HashDocument {
|
||||
return {
|
||||
plaintext,
|
||||
md5: crypto.createHash('md5').update(plaintext).digest('hex'),
|
||||
sha1: crypto.createHash('sha1').update(plaintext).digest('hex'),
|
||||
sha256: crypto.createHash('sha256').update(plaintext).digest('hex'),
|
||||
sha512: crypto.createHash('sha512').update(plaintext).digest('hex'),
|
||||
bcrypt: bcryptHash,
|
||||
created_at: new Date().toISOString()
|
||||
};
|
||||
}
|
||||
@@ -313,12 +308,10 @@ async function indexFile(filePath: string, batchSize: number, shouldResume: bool
|
||||
const bulkOperations: any[] = [];
|
||||
|
||||
// Generate hashes for all items in batch first
|
||||
const batchWithHashes = await Promise.all(
|
||||
batch.map(async (plaintext: string) => ({
|
||||
plaintext,
|
||||
hashes: await generateHashes(plaintext)
|
||||
}))
|
||||
);
|
||||
const batchWithHashes = batch.map((plaintext: string) => ({
|
||||
plaintext,
|
||||
hashes: generateHashes(plaintext)
|
||||
}));
|
||||
|
||||
if (checkDuplicates) {
|
||||
// Check which items already exist (by plaintext or any hash)
|
||||
|
||||
Referencia en una nueva incidencia
Block a user