饥荒联机版

饥荒联机版

Environment Pinger
兔~yaurrr~~ 2022 年 7 月 2 日 下午 10:31
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,
}
最后由 兔~yaurrr~~ 编辑于; 2022 年 7 月 6 日 上午 5:38
< >
正在显示第 1 - 10 条,共 10 条留言
Jabiel 2022 年 7 月 3 日 上午 2:30 
idk if it doesnt work or if im just doing something wrong...
兔~yaurrr~~ 2022 年 7 月 3 日 上午 2:46 
did you do it in steam/common/workshop/.../...?
Jabiel 2022 年 7 月 3 日 下午 12:05 
引用自 76561198067510334
did you do it in steam/common/workshop/.../...?

yeah i did still not working idk...
Jazzo Lorenzo 2022 年 7 月 3 日 下午 3:25 
yea it didnt work just like he said..
Harumii 2022 年 7 月 6 日 上午 1:22 
dont include the [/code]
Jabiel 2022 年 7 月 6 日 下午 8:14 
引用自 tims
dont include the [/code]

sorry,
what do you mean by this.
兔~yaurrr~~ 2022 年 7 月 6 日 下午 8:19 
i alr fixed it, formatting error
Annika 2022 年 7 月 6 日 下午 11:16 
Works great! Thanks! :heart_abs::cozyklei:
Jazzo Lorenzo 2022 年 7 月 7 日 上午 7:19 
It still didnt work for me i do not know why
sauktux  [开发者] 2022 年 7 月 9 日 上午 5:32 
Version 1.0.10v added a fix for the Moon Quay update crash, so manually changing files hopefully won't be necessary anymore.
< >
正在显示第 1 - 10 条,共 10 条留言
每页显示数: 1530 50