Posted 30 January 2013 - 03:42 PM
||||||||)|||||)||||||||||||)||||||||||||)-||)
I have written this Lua program that decodes this cipher I wrote in 6th grade. Here's a video demonstrating what it is. Below it is how the cipher works and how it started.
[media]http://www.youtube.com/watch?v=Z3rVS5D1Pxs[/media]
So here's how it works:
In early 6th grade I came up with this simple, yet hard to understand cipher. I originally began writing it like this:
_ _
_ _
_ _
_ _
_ _
_ _
_ _
_ _
…_
That would mean "Hi." But today I decided to write a Lua program that would decipher this. In the end I decided to use 4 characters instead of having 2. (| and -) So hi will now be this:
||||||||)|||||||||)
For every letter, there is a |. The program counts how many lines there are before a ")". If there are 5, then the letter will be the 5th letter in the alphabet, or E. If there is one line, then the letter is A. But if there are 14 lines, the counter will work and the program will stop itself from running any more tasks. This is one of the ways it makes this cipher harder to decipher.
To fix this, I have added something I call sides. There are two, and they are sides of the alphabet. Say the alphabet is arranged like this:
ABCDEFGHIJKLM
NOPQRSTUVWXYZ
When a letter starts, the side is defaulted to the top, or one. When the program detects a dash (-) before the letter, the side switches to the bottom one, or the second one. So now if the line count is 6, the letter would be 6 letters from M. Or, in simpler terms, the letter would be S.
However, there cannot be spaces in an enciphered message. For one, doing so would cause the program to be unable to separate words. A space would be a period. So a fully ciphered message such as "hello world" would be:
||||||||)|||||)||||||||||||)||||||||||||)-||).-||||||||||)-||)-|||||)||||||||||||)||||)
ALL of that explanation will no longer be in this forum post, however. Not when I add the encipher program that I am working on.
Here is the code the the decipher program:
If you read the code yourself you might find it easier to understand the way the cipher works.
Encipher code coming soon!
I have written this Lua program that decodes this cipher I wrote in 6th grade. Here's a video demonstrating what it is. Below it is how the cipher works and how it started.
[media]http://www.youtube.com/watch?v=Z3rVS5D1Pxs[/media]
So here's how it works:
In early 6th grade I came up with this simple, yet hard to understand cipher. I originally began writing it like this:
_ _
_ _
_ _
_ _
_ _
_ _
_ _
_ _
…_
That would mean "Hi." But today I decided to write a Lua program that would decipher this. In the end I decided to use 4 characters instead of having 2. (| and -) So hi will now be this:
||||||||)|||||||||)
For every letter, there is a |. The program counts how many lines there are before a ")". If there are 5, then the letter will be the 5th letter in the alphabet, or E. If there is one line, then the letter is A. But if there are 14 lines, the counter will work and the program will stop itself from running any more tasks. This is one of the ways it makes this cipher harder to decipher.
To fix this, I have added something I call sides. There are two, and they are sides of the alphabet. Say the alphabet is arranged like this:
ABCDEFGHIJKLM
NOPQRSTUVWXYZ
When a letter starts, the side is defaulted to the top, or one. When the program detects a dash (-) before the letter, the side switches to the bottom one, or the second one. So now if the line count is 6, the letter would be 6 letters from M. Or, in simpler terms, the letter would be S.
However, there cannot be spaces in an enciphered message. For one, doing so would cause the program to be unable to separate words. A space would be a period. So a fully ciphered message such as "hello world" would be:
||||||||)|||||)||||||||||||)||||||||||||)-||).-||||||||||)-||)-|||||)||||||||||||)||||)
ALL of that explanation will no longer be in this forum post, however. Not when I add the encipher program that I am working on.
Here is the code the the decipher program:
Spoiler
tArgs={...}
if #tArgs==0 then
print("Usage: dcipher <message in line>")
return
elseif not tostring(tArgs) then
print("tArgs not a string.")
elseif tArgs[1]=="help" then
print("| is a line.")
print("- swaps A-M to N-Z")
print(") finishes a letter")
print(". adds a space")
end
msg={}
lineAM={
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m"
}
lineNZ={
"n",
"o",
"p",
"q",
"r",
"s",
"t",
"u",
"v",
"w",
"x",
"y",
"z"
}
lineCount=0
side=1
function registerLetter(num)
if num>13 then
error("Program counted too many lines; cannot compute.")
return
end
if side==1 then
return lineAM[num]
elseif side==2 then
return lineNZ[num]
else
error("Variable 'side' does not equal 1 or 2!")
end
end
for i=1,string.len(tostring(tArgs[1])) do
local location=string.sub(tArgs[1],i,i)
if location=="|" then
--print("Line")
lineCount=lineCount+1
elseif location=="-" then
--print("Changing from A-M to N-Z")
side=2
elseif location==")" then
--print("Finishing letter")
local foundLetter=registerLetter(lineCount)
table.insert(msg,foundLetter)
lineCount=0
side=1
elseif location=="." then
--print("Adding a space")
table.insert(msg," ")
else
error("Unknown character found in message.")
end
--sleep(0.0001)
end
--print("Mixing table into string..")
finishedString=table.concat(msg)
print("Your decoded message:")
print(finishedString)
Encipher code coming soon!