SHOW:
|
|
- or go back to the newest paste.
1 | - | --[[ |
1 | + | layer = vortex and vortex.layer or 100 |
2 | - | Roblox Advanced Encryption Standard v1.2 |
2 | + | |
3 | - | Originally by: NoliCAIKS |
3 | + | function locate() |
4 | - | Modified by: Reinitialized |
4 | + | local x,y,z = gps.locate() |
5 | - | |
5 | + | if not x then |
6 | - | NOTICE: This cipher tool set should be treated as if it is government property, |
6 | + | error("Can't get location",0) |
7 | - | If you leak it, you will get rekt by the faggots of FAGGOTS. Don't, even THINK about it |
7 | + | end |
8 | - | |
8 | + | if X and (x ~= X or y ~= Y or z ~= Z) then |
9 | - | Changelog: |
9 | + | error("GPS desync",0) |
10 | - | v1.0: Received source code from NoliCAIKS. |
10 | + | end return x,y,z |
11 | - | v1.1: Added base64 for encoding encrypted source + encode keys |
11 | + | end |
12 | - | v1.2: Removed base64, and added improved encryption/decryption APIs |
12 | + | |
13 | - | --]] |
13 | + | local function zeroAssert(suc,err) |
14 | if not suc then | |
15 | - | Encrypt=function(message,key) |
15 | + | error(err,2) |
16 | - | local key_bytes |
16 | + | |
17 | - | if type(key) == "string" then |
17 | + | end |
18 | - | key_bytes = {} |
18 | + | |
19 | - | for key_index = 1, #key do |
19 | + | local function gotoLayer(layer) |
20 | - | key_bytes[key_index] = string.byte(key, key_index) |
20 | + | local x,y,z = locate() |
21 | - | end |
21 | + | if y < layer then |
22 | for i=1,layer-y do | |
23 | - | key_bytes = key |
23 | + | zeroAssert(turtle.up()) |
24 | end | |
25 | - | local message_length = #message |
25 | + | else |
26 | - | local key_length = #key_bytes |
26 | + | for i=1,y-layer do |
27 | - | local message_bytes = {} |
27 | + | zeroAssert(turtle.down()) |
28 | - | for message_index = 1, message_length do |
28 | + | end |
29 | - | message_bytes[message_index] = string.byte(message, message_index) |
29 | + | end |
30 | end | |
31 | - | local result_bytes = {} |
31 | + | |
32 | - | local random_seed = 0 |
32 | + | if vortex then |
33 | - | for key_index = 1, key_length do |
33 | + | vortex.rotate(0) |
34 | - | random_seed = (random_seed + key_bytes[key_index] * key_index) * 37789 + 60061 |
34 | + | else |
35 | - | random_seed = (random_seed - random_seed % 256) / 256 % 65536 |
35 | + | local ok |
36 | for i=1,4 do | |
37 | - | for message_index = 1, message_length do |
37 | + | if turtle.forward() then |
38 | - | local message_byte = message_bytes[message_index] |
38 | + | turtle.turnLeft() |
39 | - | for key_index = 1, key_length do |
39 | + | turtle.turnLeft() |
40 | - | local key_byte = key_bytes[key_index] |
40 | + | ok = true break |
41 | - | local result_index = message_index + key_index - 1 |
41 | + | else |
42 | - | local result_byte = message_byte + (result_bytes[result_index] or 0) |
42 | + | turtle.turnLeft() |
43 | - | if result_byte > 255 then |
43 | + | end |
44 | - | result_byte = result_byte - 256 |
44 | + | end |
45 | - | end |
45 | + | if not ok then |
46 | - | result_byte = result_byte + key_byte |
46 | + | error("Can't determine rotation",0) |
47 | - | if result_byte > 255 then |
47 | + | end |
48 | - | result_byte = result_byte - 256 |
48 | + | local pos = {locate()} |
49 | - | end |
49 | + | turtle.forward() |
50 | - | random_seed = (random_seed * 37789 + 60061) % 65536 |
50 | + | for k,v in pairs{locate()} do |
51 | - | result_byte = result_byte + (random_seed - random_seed % 256) / 256 |
51 | + | pos[k] = v - pos[k] |
52 | - | if result_byte > 255 then |
52 | + | end |
53 | - | result_byte = result_byte - 256 |
53 | + | if pos[1] == 0 then |
54 | - | end |
54 | + | if pos[3] == -1 then |
55 | - | result_bytes[result_index] = result_byte |
55 | + | -- Facing north |
56 | - | end |
56 | + | else |
57 | -- Facing south | |
58 | - | local result_buffer = {} |
58 | + | turtle.turnLeft() |
59 | - | local result_buffer_index = 1 |
59 | + | turtle.turnLeft() |
60 | - | for result_index = 1, #result_bytes do |
60 | + | end |
61 | - | local result_byte = result_bytes[result_index] |
61 | + | elseif pos[1] == 1 then |
62 | - | result_buffer[result_buffer_index] = string.format("%02x", result_byte) |
62 | + | -- Facing east |
63 | - | result_buffer_index = result_buffer_index + 1 |
63 | + | turtle.turnLeft() |
64 | else | |
65 | - | return table.concat(result_buffer) |
65 | + | -- Facing west |
66 | - | end; |
66 | + | turtle.turnRight() |
67 | - | Decrypt=function(cipher,key) |
67 | + | end |
68 | - | local key_bytes |
68 | + | end |
69 | - | if type(key) == "string" then |
69 | + | |
70 | - | key_bytes = {} |
70 | + | ro = vortex and vortex.ro or 0 |
71 | - | for key_index = 1, #key do |
71 | + | function rotate(n) |
72 | - | key_bytes[key_index] = string.byte(key, key_index) |
72 | + | ro,n = ro%4,n%4 |
73 | - | end |
73 | + | if ro < 0 then |
74 | ro = ro + 4 | |
75 | - | key_bytes = key |
75 | + | end |
76 | if math.abs(ro-n-4) < | |
77 | - | local cipher_raw_length = #cipher |
77 | + | math.abs(ro-n) then |
78 | - | local key_length = #key_bytes |
78 | + | ro = ro - 4 |
79 | - | local cipher_bytes = {} |
79 | + | end |
80 | - | local cipher_length = 0 |
80 | + | while ro < n do |
81 | - | local cipher_bytes_index = 1 |
81 | + | turtle.turnLeft() |
82 | - | for byte_str in string.gmatch(cipher, "%x%x") do |
82 | + | end |
83 | - | cipher_length = cipher_length + 1 |
83 | + | while ro > n do |
84 | - | cipher_bytes[cipher_length] = tonumber(byte_str, 16) |
84 | + | turtle.turnRight() |
85 | end ro = (ro + 4)%4 | |
86 | - | local random_bytes = {} |
86 | + | end |
87 | - | local random_seed = 0 |
87 | + | |
88 | - | for key_index = 1, key_length do |
88 | + | local old = vortex and vortex.old or { |
89 | - | random_seed = (random_seed + key_bytes[key_index] * key_index) * 37789 + 60061 |
89 | + | turnLeft = turtle.turnLeft; |
90 | - | random_seed = (random_seed - random_seed % 256) / 256 % 65536 |
90 | + | turnRight = turtle.turnRight; |
91 | forward = turtle.forward; | |
92 | - | for random_index = 1, (cipher_length - key_length + 1) * key_length do |
92 | + | back = turtle.back; |
93 | - | random_seed = (random_seed * 37789 + 60061) % 65536 |
93 | + | down = turtle.down; |
94 | - | random_bytes[random_index] = (random_seed - random_seed % 256) / 256 |
94 | + | up = turtle.up; |
95 | } | |
96 | - | local random_index = #random_bytes |
96 | + | |
97 | - | local last_key_byte = key_bytes[key_length] |
97 | + | boundsFunc = vortex and vortex.boundsFunc or function(x,y,z) |
98 | - | local result_bytes = {} |
98 | + | if x > 1111 then return false end |
99 | - | for cipher_index = cipher_length, key_length, -1 do |
99 | + | if x < 1073 then return false end |
100 | - | local result_byte = cipher_bytes[cipher_index] - last_key_byte |
100 | + | if z > 1703 then return false end |
101 | - | if result_byte < 0 then |
101 | + | if z < 1649 then return false end |
102 | - | result_byte = result_byte + 256 |
102 | + | if z < 1665 and x > 1086 then |
103 | - | end |
103 | + | return false |
104 | - | result_byte = result_byte - random_bytes[random_index] |
104 | + | end return y < 101 and y > 76 |
105 | - | random_index = random_index - 1 |
105 | + | end |
106 | - | if result_byte < 0 then |
106 | + | |
107 | - | result_byte = result_byte + 256 |
107 | + | X,Y,Z = gps.locate() |
108 | - | end |
108 | + | |
109 | - | for key_index = key_length - 1, 1, -1 do |
109 | + | function turtle.turnLeft() |
110 | - | cipher_index = cipher_index - 1 |
110 | + | old.turnLeft() ro = (ro + 1)%4 |
111 | - | local cipher_byte = cipher_bytes[cipher_index] - key_bytes[key_index] |
111 | + | end |
112 | - | if cipher_byte < 0 then |
112 | + | function turtle.turnRight() |
113 | - | cipher_byte = cipher_byte + 256 |
113 | + | old.turnRight() ro = (ro + 3)%4 |
114 | - | end |
114 | + | end |
115 | - | cipher_byte = cipher_byte - result_byte |
115 | + | function turtle.forward() |
116 | - | if cipher_byte < 0 then |
116 | + | local x,z = X,Z |
117 | - | cipher_byte = cipher_byte + 256 |
117 | + | if ro == 0 then |
118 | - | end |
118 | + | z = z - 1 |
119 | - | cipher_byte = cipher_byte - random_bytes[random_index] |
119 | + | elseif ro == 1 then |
120 | - | random_index = random_index - 1 |
120 | + | x = x - 1 |
121 | - | if cipher_byte < 0 then |
121 | + | elseif ro == 2 then |
122 | - | cipher_byte = cipher_byte + 256 |
122 | + | z = z + 1 |
123 | - | end |
123 | + | elseif ro == 3 then |
124 | - | cipher_bytes[cipher_index] = cipher_byte |
124 | + | x = x + 1 |
125 | - | end |
125 | + | |
126 | - | result_bytes[cipher_index] = result_byte |
126 | + | if not boundsFunc(x,Y,z) then |
127 | return false,"Outside bounds" | |
128 | - | local result_characters = {} |
128 | + | elseif not old.forward() then |
129 | - | for result_index = 1, #result_bytes do |
129 | + | return false,"Can't move forward" |
130 | - | result_characters[result_index] = string.char(result_bytes[result_index]) |
130 | + | end X,Z = x,z return true |
131 | end | |
132 | - | return table.concat(result_characters) |
132 | + | function turtle.back() |
133 | - | end; |
133 | + | local x,z = X,Z |
134 | if ro == 0 then | |
135 | - | _G.security={ |
135 | + | z = z + 1 |
136 | - | Encrypt=Encrypt; |
136 | + | elseif ro == 1 then |
137 | - | Decrypt=Decrypt; |
137 | + | x = x + 1 |
138 | - | }; |
138 | + | elseif ro == 2 then |
139 | z = z - 1 | |
140 | elseif ro == 3 then | |
141 | x = x - 1 | |
142 | end | |
143 | if not boundsFunc(x,Y,z) then | |
144 | return false,"Outside bounds" | |
145 | elseif not old.back() then | |
146 | return false,"Can't move back" | |
147 | end X,Z = x,z return true | |
148 | end | |
149 | function turtle.up() | |
150 | if not boundsFunc(X,Y+1,Z) then | |
151 | return false,"Outside bounds" | |
152 | elseif not old.up() then | |
153 | return false,"Can't move up" | |
154 | end Y = Y + 1 return true | |
155 | end | |
156 | function turtle.down() | |
157 | if not boundsFunc(X,Y-1,Z) then | |
158 | return false,"Outside bounds" | |
159 | elseif not old.down() then | |
160 | return false,"Can't move down" | |
161 | end Y = Y - 1 return true | |
162 | end | |
163 | ||
164 | local function succeedOrUp(f) | |
165 | local s,e = f() | |
166 | while not s do | |
167 | if e == "Outside bounds" then | |
168 | error("Has to move outside bounds",0) | |
169 | end zeroAssert(turtle.up()) | |
170 | s,e = f() | |
171 | end | |
172 | end | |
173 | ||
174 | function goto(X,Y,Z,l) | |
175 | --gotoLayer(l or Y) | |
176 | local x,y,z = vortex.locate() | |
177 | x,y,z = x-X,y-Y,z-Z | |
178 | rotate(z < 0 and 2 or 0) | |
179 | for i=1,math.abs(z) do | |
180 | succeedOrUp(turtle.forward) | |
181 | end | |
182 | rotate(x > 0 and 1 or -1) | |
183 | for i=1,math.abs(x) do | |
184 | succeedOrUp(turtle.forward) | |
185 | end gotoLayer(Y) | |
186 | end | |
187 | ||
188 | function goto_old(X,Y,Z,l) | |
189 | gotoLayer(l == true and Y or l or layer) | |
190 | local x,y,z = vortex.locate() | |
191 | x,y,z = x-X,y-Y,z-Z | |
192 | rotate(z < 0 and 2 or 0) | |
193 | for i=1,math.abs(z) do | |
194 | zeroAssert(turtle.forward()) | |
195 | end | |
196 | rotate(x > 0 and 1 or -1) | |
197 | for i=1,math.abs(x) do | |
198 | zeroAssert(turtle.forward()) | |
199 | end | |
200 | if y > 0 then | |
201 | for i=1,y do | |
202 | zeroAssert(turtle.down()) | |
203 | end | |
204 | else | |
205 | for i=1,-y do | |
206 | zeroAssert(turtle.up()) | |
207 | end | |
208 | end | |
209 | end |