refactor: 🚨 Make more class methods static

This commit is contained in:
Jesse Wierzbinski 2024-10-03 19:02:13 +02:00
parent 5ec19f037a
commit 2537e3cd48
No known key found for this signature in database
8 changed files with 40 additions and 44 deletions

View file

@ -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;
};