[Bug] Fix local save encoding crash and Psychic anim (#5775)

* fix error: utf8 to base64

* fix error: space missed
This commit is contained in:
lxy-lxy-lxy 2025-05-05 21:32:56 +08:00 committed by GitHub
parent e3028c6219
commit 7547b37e85
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 7 deletions

View File

@ -118,15 +118,17 @@ export function getDataTypeKey(dataType: GameDataType, slotId = 0): string {
}
export function encrypt(data: string, bypassLogin: boolean): string {
return (bypassLogin ? (data: string) => btoa(data) : (data: string) => AES.encrypt(data, saveKey))(
data,
) as unknown as string; // TODO: is this correct?
return (bypassLogin
? (data: string) => btoa(encodeURIComponent(data))
: (data: string) => AES.encrypt(data, saveKey))(data) as unknown as string; // TODO: is this correct?
}
export function decrypt(data: string, bypassLogin: boolean): string {
return (bypassLogin ? (data: string) => atob(data) : (data: string) => AES.decrypt(data, saveKey).toString(enc.Utf8))(
data,
);
return (
bypassLogin
? (data: string) => decodeURIComponent(atob(data))
: (data: string) => AES.decrypt(data, saveKey).toString(enc.Utf8)
)(data);
}
export interface SystemSaveData {