diff --git a/backend/.gitignore b/backend/.gitignore index da641cf7..32183cd3 100644 --- a/backend/.gitignore +++ b/backend/.gitignore @@ -5,4 +5,6 @@ uploads .ipynb_checkpoints *.db _test -Pipfile \ No newline at end of file +Pipfile + +/data \ No newline at end of file diff --git a/src/lib/utils/index.ts b/src/lib/utils/index.ts index d9f6fd7d..2029604e 100644 --- a/src/lib/utils/index.ts +++ b/src/lib/utils/index.ts @@ -127,38 +127,3 @@ export const findWordIndices = (text) => { return matches; }; - -export const calculateSHA256 = async (file) => { - console.log(file); - // Create a FileReader to read the file asynchronously - const reader = new FileReader(); - - // Define a promise to handle the file reading - const readFile = new Promise((resolve, reject) => { - reader.onload = () => resolve(reader.result); - reader.onerror = reject; - }); - - // Read the file as an ArrayBuffer - reader.readAsArrayBuffer(file); - - try { - // Wait for the FileReader to finish reading the file - const buffer = await readFile; - - // Convert the ArrayBuffer to a Uint8Array - const uint8Array = new Uint8Array(buffer); - - // Calculate the SHA-256 hash using Web Crypto API - const hashBuffer = await crypto.subtle.digest('SHA-256', uint8Array); - - // Convert the hash to a hexadecimal string - const hashArray = Array.from(new Uint8Array(hashBuffer)); - const hashHex = hashArray.map((byte) => byte.toString(16).padStart(2, '0')).join(''); - - return `sha256:${hashHex}`; - } catch (error) { - console.error('Error calculating SHA-256 hash:', error); - throw error; - } -};