Created
November 21, 2022 13:58
-
-
Save yakovenkodenis/7e310701788cfd9e7e418960a084a504 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_unmask(payload, maskingKey) { | |
const result = Buffer.alloc(payload.byteLength); | |
for (let i = 0; i < payload.byteLength; ++i) { | |
const j = i % 4; | |
const maskingKeyByteShift = j === 3 ? 0 : (3 - j) << 3; | |
const maskingKeyByte = (maskingKeyByteShift === 0 ? maskingKey : maskingKey >>> maskingKeyByteShift) & 0b11111111; | |
const transformedByte = maskingKeyByte ^ payload.readUInt8(i); | |
result.writeUInt8(transformedByte, i); | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment