Hex
New Member
Posts: 19
|
Post by Hex on Jun 6, 2017 9:17:33 GMT
DIFFICULTY: EASY
Given "Wjajwxj Hnumjw", a shift cipher encrypted string, write an algorithm that reverses the shift cipher and outputs two meaningful words derived.
|
|
|
Post by cntkillme on Jun 12, 2017 10:32:05 GMT
ANSWER: Reverse Cipher
Key: -5
local enc = [[Wjajwxj Hnumjw]]
local BAU = string.byte('A') local BAL = string.byte('a')
for key = 0, 25 do local dec = enc:gsub("%a", function(v) v = v:byte() if v < BAL then -- upper v = BAU + ((v - BAU) + key)%26 else v = BAL + ((v - BAL) + key)%26 end
return string.char(v) end)
if key > 12 then -- shortest path passed 12 would be going backwards print(key - 26, dec) else print(key, dec)
end end
|
|