diff --git a/src/ssn/decryption/decryptChunk.ts b/src/ssn/decryption/decryptChunk.ts index afd5261..3761fde 100644 --- a/src/ssn/decryption/decryptChunk.ts +++ b/src/ssn/decryption/decryptChunk.ts @@ -3,12 +3,10 @@ import updateKeys from './lib/updateKeys'; export default function getDecryptor(decryptionKeys: [number, number, number]) { let [key0, key1, key2] = decryptionKeys; - return (encryptedChunk: Buffer) => { - //const decryptedChunk = Buffer.alloc(encryptedChunk.length); - - for (let i = 0; i < encryptedChunk.length; i += 1) { + return (chunk: Buffer) => { + for (let i = 0; i < chunk.length; i += 1) { //read byte - let curChar = encryptedChunk.readUInt8(i); + let curChar = chunk.readUInt8(i); //decrypt byte const keyPart = (key2 | 2) & 0xFFFF; @@ -19,11 +17,9 @@ export default function getDecryptor(decryptionKeys: [number, number, number]) { [key0, key1, key2] = updateKeys([key0, key1, key2], curChar); //write byte - //decryptedChunk.writeUInt8(curChar, i); - encryptedChunk.writeUInt8(curChar, i); + chunk.writeUInt8(curChar, i); } - //return decryptedChunk; - return encryptedChunk; + return chunk; }; }