feat/0.2:add theme setting and about page setting and support use email and password login

This commit is contained in:
lethe committed 2025-07-24 10:28:42 +08:00
1 parent 58292b0e6e
commit ca2b732952
85 files changed
+5797 -816

No files matched your search

+35
View File
@@ -8,3 +8,38 @@ import CryptoJS from "crypto-js";
export const md5Encrypt = (text: string): string => {
return CryptoJS.MD5(text).toString();
};
/**
* SHA256 encrypt function
* @param text text to encrypt
* @returns SHA256 encrypted string
*/
export const sha256Encrypt = (text: string): string => {
return CryptoJS.SHA256(text).toString();
};
/**
* Calculate SHA256 hash of a file
* @param file File to calculate hash for
* @returns Promise resolving to SHA256 hash string
*/
export const calculateFileSha256 = (file: File): Promise<string> => {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = (event) => {
try {
const binary = event.target?.result;
if (binary) {
const hash = CryptoJS.SHA256(CryptoJS.lib.WordArray.create(binary as any)).toString();
resolve(hash);
} else {
reject(new Error("Failed to read file"));
}
} catch (error) {
reject(error);
}
};
reader.onerror = (error) => reject(error);
reader.readAsArrayBuffer(file);
});
};