mirror of
https://github.com/versia-pub/server.git
synced 2026-04-27 20:59:15 +02:00
refactor: 🚨 Make more class methods static
This commit is contained in:
parent
5ec19f037a
commit
2537e3cd48
8 changed files with 40 additions and 44 deletions
|
|
@ -4,17 +4,12 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* Utility class for hashing media files.
|
||||
* Generates a SHA-256 hash for a given file.
|
||||
* @param file - The file to hash.
|
||||
* @returns A promise that resolves to the SHA-256 hash of the file in hex format.
|
||||
*/
|
||||
export class MediaHasher {
|
||||
/**
|
||||
* Generates a SHA-256 hash for a given file.
|
||||
* @param file - The file to hash.
|
||||
* @returns A promise that resolves to the SHA-256 hash of the file in hex format.
|
||||
*/
|
||||
public async getMediaHash(file: File): Promise<string> {
|
||||
const arrayBuffer = await file.arrayBuffer();
|
||||
const hash = new Bun.SHA256().update(arrayBuffer).digest("hex");
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
export const getMediaHash = async (file: File): Promise<string> => {
|
||||
const arrayBuffer = await file.arrayBuffer();
|
||||
const hash = new Bun.SHA256().update(arrayBuffer).digest("hex");
|
||||
return hash;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue