mirror of
https://github.com/daydreamer-json/ak-endfield-api-archive.git
synced 2026-04-06 23:52:21 +02:00
feat: implement resource index decryption
- Add `cipher` utility for resource index decryption/encryption - Automatically decrypt `index_initial.json` and `index_main.json` during archiving - pages: Update `ResourcesTab` to display links to decrypted versions of index files - Update README to reflect that some raw data is now decrypted
This commit is contained in:
28
src/utils/cipher.ts
Normal file
28
src/utils/cipher.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
function decryptResIndex(encData: Uint8Array, key: string): Uint8Array {
|
||||
const keyBytes = Buffer.from(key, 'utf-8');
|
||||
const keyLength = keyBytes.length;
|
||||
const result = new Uint8Array(encData.length);
|
||||
for (let i = 0; i < encData.length; i++) {
|
||||
const encByte = encData[i]!;
|
||||
const keyByte = keyBytes[i % keyLength]!;
|
||||
result[i] = (encByte - keyByte + 256) % 256;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function encryptResIndex(plainData: Uint8Array, key: string): Uint8Array {
|
||||
const keyBytes = Buffer.from(key, 'utf-8');
|
||||
const keyLength = keyBytes.length;
|
||||
const result = new Uint8Array(plainData.length);
|
||||
for (let i = 0; i < plainData.length; i++) {
|
||||
const plainByte = plainData[i]!;
|
||||
const keyByte = keyBytes[i % keyLength]!;
|
||||
result[i] = (plainByte + keyByte) % 256;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export default {
|
||||
decryptResIndex,
|
||||
encryptResIndex,
|
||||
};
|
||||
@@ -12,6 +12,11 @@ type AllRequired<T> = Required<{
|
||||
|
||||
type ConfigType = AllRequired<
|
||||
Freeze<{
|
||||
cipher: {
|
||||
akEndfield: {
|
||||
resIndexKey: string;
|
||||
};
|
||||
};
|
||||
network: {
|
||||
api: {
|
||||
akEndfield: {
|
||||
@@ -69,6 +74,11 @@ type ConfigType = AllRequired<
|
||||
>;
|
||||
|
||||
const initialConfig: ConfigType = {
|
||||
cipher: {
|
||||
akEndfield: {
|
||||
resIndexKey: 'Assets/Beyond/DynamicAssets/Gameplay/UI/Fonts/', // via reversing
|
||||
},
|
||||
},
|
||||
network: {
|
||||
api: {
|
||||
akEndfield: {
|
||||
|
||||
Reference in New Issue
Block a user