Don't Starve Together

Don't Starve Together

Environment Pinger
2 Jul, 2022 @ 10:31pm
How to fix Environment Pinger for Moon Quay
replace scripts/environmentpinger/encryptor with the following

-- XOR cipher. -- We can count up to 256 -- Valid interval: (32;255] local function compute_hash(s) local p = 31 local m = 1e9 + 9 local hash_value = 0 local p_pow = 1 for i=1, #s do local c = string.byte(s:sub(i,i)) hash_value = (hash_value + (c - string.byte('a') + 1) * p_pow) % m p_pow = (p_pow * p) % m end return hash_value end local function toBits(num,forced_size) local bits_reversed = {} if type(num) == "string" then num = compute_hash(num) end while num > 0 do local bit = num%2 bits_reversed[#bits_reversed+1] = bit num = math.floor(num/2) end local bits = {} for i = #bits_reversed,1,-1 do table.insert(bits,bits_reversed) end
if forced_size then
while forced_size > #bits do
table.insert(bits,1,"0")
end
end
return table.concat(bits)
end

local function toDec(bits)

local bit_size = #bits
local binary_map = {}
for bin = bit_size-1,0,-1 do
table.insert(binary_map,2^bin)
end

local dec = 0
local counter = 1
for bit in bits:gmatch(".") do
if bit == "1" then
dec = dec+binary_map[counter]
end
counter = counter+1
end

return dec
end

local function xor(a,b)
return bit.bxor(a,b)
end


--Encryption and Decryption Algorithm for XOR
local function E(str,cipher)
cipher = cipher or "10010001"
local byte_list = {}
--Characters to bytes
for char in str:gmatch(".") do
table.insert(byte_list,string.byte(char))
end
local xor_list = {}
for _,num in pairs(byte_list) do
--Bytes to numbers
local cipher_num = toDec(cipher)
--Numbers to XOR
local num_xor = xor(num,cipher_num)

local char = string.char(num_xor)
table.insert(xor_list,char)
end
return table.concat(xor_list,"")
end

return {
E = E,
toBits = toBits,
toDec = toDec,
}
Last edited by ; 6 Jul, 2022 @ 5:38am
< >
Showing 1-10 of 10 comments
Jabiel 3 Jul, 2022 @ 2:30am 
idk if it doesnt work or if im just doing something wrong...
3 Jul, 2022 @ 2:46am 
did you do it in steam/common/workshop/.../...?
Jabiel 3 Jul, 2022 @ 12:05pm 
Originally posted by 76561198067510334:
did you do it in steam/common/workshop/.../...?

yeah i did still not working idk...
Jazzo Lorenzo 3 Jul, 2022 @ 3:25pm 
yea it didnt work just like he said..
Harumii 6 Jul, 2022 @ 1:22am 
dont include the [/code]
Jabiel 6 Jul, 2022 @ 8:14pm 
Originally posted by tims:
dont include the [/code]

sorry,
what do you mean by this.
6 Jul, 2022 @ 8:19pm 
i alr fixed it, formatting error
Annika 6 Jul, 2022 @ 11:16pm 
Works great! Thanks! :heart_abs::cozyklei:
Jazzo Lorenzo 7 Jul, 2022 @ 7:19am 
It still didnt work for me i do not know why
sauktux  [developer] 9 Jul, 2022 @ 5:32am 
Version 1.0.10v added a fix for the Moon Quay update crash, so manually changing files hopefully won't be necessary anymore.
< >
Showing 1-10 of 10 comments
Per page: 1530 50