Base64Decode cleaning
This commit is contained in:
parent
fa88b665b6
commit
c492672f6a
1 changed files with 13 additions and 7 deletions
|
|
@ -113,15 +113,22 @@ function RemoveHeaders(buffer, csHeader = CSHARP_HEADER) {
|
|||
return buffer.subarray(lengthCount);
|
||||
}
|
||||
|
||||
// Thanks to KayDeeTee https://github.com/KayDeeTee/Hollow-Knight-SaveManager and bloodorca https://github.com/bloodorca/hollow (base64.js)
|
||||
function Base64Decode(buffer) {
|
||||
buffer = new Uint8Array(buffer).slice();
|
||||
buffer = buffer.map(v => BASE64_DECODE_TABLE.get(v))
|
||||
{
|
||||
let p = buffer.indexOf(64);
|
||||
buffer = buffer.subarray(0, p != -1 ? p : buffer.length);
|
||||
buffer = buffer.map(v => BASE64_DECODE_TABLE.get(v));
|
||||
|
||||
// The indexOf() method returns the first index at which a given element can be found in the array, or -1 if it is not present.
|
||||
let p = buffer.indexOf(64);
|
||||
let end;
|
||||
|
||||
if (p != -1) {
|
||||
end = p;
|
||||
} else {
|
||||
end = buffer.length;
|
||||
}
|
||||
|
||||
buffer = buffer.subarray(0, end);
|
||||
|
||||
let output = new Uint8Array(3 * buffer.length / 4);
|
||||
let continuous = Math.floor(buffer.length / 4) * 4;
|
||||
|
||||
|
|
@ -142,7 +149,6 @@ function Base64Decode(buffer) {
|
|||
return output;
|
||||
}
|
||||
|
||||
// Thanks to KayDeeTee https://github.com/KayDeeTee/Hollow-Knight-SaveManager and bloodorca https://github.com/bloodorca/hollow (functions.js)
|
||||
// Decrypt the Uint8Array Buffer using aesjs and a predefined AES key + remove pkcs7 padding
|
||||
function AESDecryption(buffer) {
|
||||
let output = ECB_STREAM_CIPHER.decrypt(buffer);
|
||||
|
|
|
|||
Loading…
Reference in a new issue