变更私人影库的key值方式

This commit is contained in:
mtvpls
2025-12-26 21:14:31 +08:00
parent df78abaf11
commit 3050cd48a9
15 changed files with 120 additions and 84 deletions
+28
View File
@@ -1,5 +1,33 @@
import CryptoJS from 'crypto-js';
/**
* 生成 SHA256 哈希值
* @param data 要哈希的数据
* @returns SHA256 哈希值(十六进制字符串)
*/
export function sha256(data: string): string {
return CryptoJS.SHA256(data).toString(CryptoJS.enc.Hex);
}
/**
* 生成文件夹的唯一 key
* @param folderName 文件夹名称
* @param existingKeys 已存在的 key 集合,用于检测冲突
* @returns 唯一的 keySHA256 的前10位)
*/
export function generateFolderKey(folderName: string, existingKeys: Set<string> = new Set()): string {
let hash = sha256(folderName);
let key = hash.substring(0, 10);
// 如果遇到冲突,继续 sha256 直到不冲突
while (existingKeys.has(key)) {
hash = sha256(hash);
key = hash.substring(0, 10);
}
return key;
}
/**
* 简单的对称加密工具
* 使用 AES 加密算法
+2 -1
View File
@@ -18,7 +18,8 @@ const VIDEOINFO_CACHE: Map<string, VideoInfoCacheEntry> = new Map();
export interface MetaInfo {
folders: {
[folderName: string]: {
[key: string]: {
folderName: string; // 原始文件夹名称
tmdb_id: number;
title: string;
poster_path: string | null;