Advertisement
Guest User

Untitled

a guest
Jul 20th, 2019
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. module.exports = {
  2. rotateEncryptionKey(key){
  3. key = Math.imul(key, 1540483477) | 0
  4. key = (Math.imul(key >>> 24 ^ key, 1540483477) | 0) ^ 114296087
  5. key = Math.imul(key >>> 13 ^ key, 1540483477) | 0
  6. return key >>> 15 ^ key
  7. },
  8. rotateBufferBytes(buffer, key){
  9. for(let i = 0; i < buffer.byteLength; i++) buffer.writeUInt8(buffer.readUInt8(i) ^ key >>> (i % 4 * 8) & 255, i)
  10. return buffer
  11. },
  12. uncompressBuffer(input, output){
  13. for(let i = 0, j = 0, n = input.length; i < n;){
  14. const byte = input[i++]
  15. let literalsLength = byte >> 4
  16. if(literalsLength > 0){
  17. let length = literalsLength + 240
  18. while(length === 255){
  19. length = input[i++]
  20. literalsLength += length
  21. }
  22. const end = i + literalsLength
  23. while(i < end) output[j++] = input[i++]
  24. if(i === n) return output
  25. }
  26. const offset = input[i++] | (input[i++] << 8)
  27. if(offset === 0 || offset > j) return -(i - 2)
  28. let matchLength = byte & 15
  29. let length = matchLength + 240
  30. while(length === 255){
  31. length = input[i++]
  32. matchLength += length
  33. }
  34. let pos = j - offset
  35. const end = j + matchLength + 4
  36. while(j < end) output[j++] = output[pos++]
  37. }
  38. return output
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement