mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-11-12 04:03:42 +08:00
修改: app/api/bedrock.ts
修改: app/client/api.ts 修改: app/store/access.ts 新文件: app/utils/encryption.ts 修改: package.json
This commit is contained in:
22
app/utils/encryption.ts
Normal file
22
app/utils/encryption.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { AES, enc } from "crypto-js";
|
||||
|
||||
const SECRET_KEY = "your-secret-key"; // Replace this with a secure, randomly generated key
|
||||
|
||||
export function encrypt(data: string): string {
|
||||
try {
|
||||
return AES.encrypt(data, SECRET_KEY).toString();
|
||||
} catch (error) {
|
||||
console.error("Encryption failed:", error);
|
||||
return data; // Fallback to unencrypted data if encryption fails
|
||||
}
|
||||
}
|
||||
|
||||
export function decrypt(encryptedData: string): string {
|
||||
try {
|
||||
const bytes = AES.decrypt(encryptedData, SECRET_KEY);
|
||||
return bytes.toString(enc.Utf8);
|
||||
} catch (error) {
|
||||
console.error("Decryption failed:", error);
|
||||
return encryptedData; // Fallback to the original data if decryption fails
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user