Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
bf6685d8
Commit
bf6685d8
authored
Jan 11, 2024
by
Timothy J. Baek
Browse files
chore: conflict
parent
8b62d8ac
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
36 deletions
+3
-36
backend/.gitignore
backend/.gitignore
+3
-1
src/lib/utils/index.ts
src/lib/utils/index.ts
+0
-35
No files found.
backend/.gitignore
View file @
bf6685d8
...
@@ -5,4 +5,6 @@ uploads
...
@@ -5,4 +5,6 @@ uploads
.ipynb_checkpoints
.ipynb_checkpoints
*.db
*.db
_test
_test
Pipfile
Pipfile
\ No newline at end of file
/data
\ No newline at end of file
src/lib/utils/index.ts
View file @
bf6685d8
...
@@ -127,38 +127,3 @@ export const findWordIndices = (text) => {
...
@@ -127,38 +127,3 @@ export const findWordIndices = (text) => {
return
matches
;
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
;
}
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment