@@ -30,6 +30,7 @@ function EncryptStrings:CreateEncrypionService()
3030 local secret_key_6 = math.random (0 , 63 ) -- 6-bit arbitrary integer (0..63)
3131 local secret_key_7 = math.random (0 , 127 ) -- 7-bit arbitrary integer (0..127)
3232 local secret_key_44 = math.random (0 , 17592186044415 ) -- 44-bit arbitrary integer (0..17592186044415)
33+ local secret_key_8 = math.random (0 , 255 ); -- 8-bit arbitrary integer (0..255)
3334
3435 local floor = math.floor
3536
@@ -93,8 +94,11 @@ function EncryptStrings:CreateEncrypionService()
9394 set_seed (seed )
9495 local len = string.len (str )
9596 local out = {}
97+ local prevVal = secret_key_8 ;
9698 for i = 1 , len do
97- out [i ] = string.char ((string.byte (str , i ) + get_next_pseudo_random_byte ()) % 256 );
99+ local byte = string.byte (str , i );
100+ out [i ] = string.char ((byte - (get_next_pseudo_random_byte () + prevVal )) % 256 );
101+ prevVal = byte ;
98102 end
99103 return table.concat (out ), seed ;
100104 end
106110 local random = math.random;
107111 local remove = table.remove;
108112 local char = string.char;
109- local param_mul_8 = ]] .. tostring (param_mul_8 ) .. [[
110- local param_mul_45 = ]] .. tostring (param_mul_45 ) .. [[
111- local param_add_45 = ]] .. tostring (param_add_45 ) .. [[
112113 local state_45 = 0
113114 local state_8 = 2
114115 local digits = {}
129130 local prev_values = {}
130131 local function get_next_pseudo_random_byte()
131132 if #prev_values == 0 then
132- state_45 = (state_45 * param_mul_45 + param_add_45) % 35184372088832
133+ state_45 = (state_45 * ]] .. tostring ( param_mul_45 ) .. [[ + ]] .. tostring ( param_add_45 ) .. [[ ) % 35184372088832
133134 repeat
134- state_8 = state_8 * param_mul_8 % 257
135+ state_8 = state_8 * ]] .. tostring ( param_mul_8 ) .. [[ % 257
135136 until state_8 ~= 1
136137 local r = state_8 % 32
137138 local n = floor(state_45 / 2 ^ (13 - (state_8 - r) / 32)) % 2 ^ 32 / 2 ^ r
150151 local realStrings = {};
151152 STRINGS = setmetatable({}, {
152153 __index = realStrings;
154+ __metatable = nil;
153155 });
154- function DECRYPT(str, seed)
155- if(realStrings[seed]) then
156- return seed;
157- end
158- state_45 = seed % 35184372088832
159- state_8 = seed % 255 + 2
160- prev_values = {};
161- local len = string.len(str);
162- realStrings[seed] = "";
163- for i=1, len do
164- realStrings[seed] = realStrings[seed] .. charmap[(string.byte(str, i) - get_next_pseudo_random_byte()) % 256 + 1];
156+ function DECRYPT(str, seed)
157+ local realStringsLocal = realStrings;
158+ if(realStringsLocal[seed]) then else
159+ prev_values = {};
160+ local chars = charmap;
161+ state_45 = seed % 35184372088832
162+ state_8 = seed % 255 + 2
163+ local len = string.len(str);
164+ realStringsLocal[seed] = "";
165+ local prevVal = ]] .. tostring (secret_key_8 ) .. [[ ;
166+ for i=1, len do
167+ prevVal = (string.byte(str, i) + get_next_pseudo_random_byte() + prevVal) % 256
168+ realStringsLocal[seed] = realStringsLocal[seed] .. chars[prevVal + 1];
169+ end
165170 end
166171 return seed;
167172 end
@@ -175,6 +180,7 @@ end]]
175180 param_mul_45 = param_mul_45 ,
176181 param_mul_8 = param_mul_8 ,
177182 param_add_45 = param_add_45 ,
183+ secret_key_8 = secret_key_8 ,
178184 genCode = genCode ,
179185 }
180186end
0 commit comments