...

View Full Version : Ceasar Cipher Cracker, having problems



KashSmith100001
01-12-2013, 05:13 PM
I am trying to write a program in Just Basic to crack a ceasar cipher, by doing a shift of 1 letter, then 2 letters, and on to 26 letters, and output to a text file. The idea is to try every possible cipher, so you can crack any ceasar cipher. I've got it to the point where it should do the 1st shift, the problem is if you input "b", it shows "a", but if you input "bbb", it still only shows "a", I need it to show "aaa", if you know what I mean, please help if you can, I'm pulling my hair out over here! (and thanks!)



dim alpha$(26)
dim alpha1$(26) 'for a one character shift


alpha$(1) = "a"
alpha$(2) = "b"
alpha$(3) = "c"
alpha$(4) = "d"
alpha$(5) = "e"
alpha$(6) = "f"
alpha$(7) = "g"
alpha$(8) = "h"
alpha$(9) = "i"
alpha$(10) = "j"
alpha$(11) = "k"
alpha$(12) = "l"
alpha$(13) = "m"
alpha$(14) = "n"
alpha$(15) = "o"
alpha$(16) = "p"
alpha$(17) = "q"
alpha$(18) = "r"
alpha$(19) = "s"
alpha$(20) = "t"
alpha$(21) = "u"
alpha$(22) = "v"
alpha$(23) = "w"
alpha$(24) = "x"
alpha$(25) = "y"
alpha$(26) = "z"

alpha1$(1) = "b"
alpha1$(2) = "c"
alpha1$(3) = "d"
alpha1$(4) = "e"
alpha1$(5) = "f"
alpha1$(6) = "g"
alpha1$(7) = "h"
alpha1$(8) = "i"
alpha1$(9) = "j"
alpha1$(10) = "k"
alpha1$(11) = "l"
alpha1$(12) = "m"
alpha1$(13) = "n"
alpha1$(14) = "o"
alpha1$(15) = "p"
alpha1$(16) = "q"
alpha1$(17) = "r"
alpha1$(18) = "s"
alpha1$(19) = "t"
alpha1$(20) = "u"
alpha1$(21) = "v"
alpha1$(22) = "w"
alpha1$(23) = "x"
alpha1$(24) = "y"
alpha1$(25) = "z"
alpha1$(26) = "a"


input "Encrypted message:" ; encmsg$

for count = 1 to LEN(encmsg$)

cc$ = MID$(encmsg$, count, 1)

if cc$ = alpha1$(count) then
newmsg1$ = newmsg1$ + alpha$(count)
end if

next count

print newmsg1$

KashSmith100001
01-12-2013, 05:23 PM
Thanks, but I finally figured it out.

KashSmith100001
01-12-2013, 05:24 PM
I do have another question though, how to you delete a threat, I don't see an option to delete my thread anywhere now that I've solved the problem.

Redcoder
01-12-2013, 07:23 PM
Why delete? Would be better to even post how you solved it for other users. I don't use the Microsoft Stack(ASP.NET, VB, C#) but I think that the solution would be useful to another guy. So, do post your answer...thats the whole point of forums I think - the good of all. :)

AceInfinity
01-20-2013, 02:22 PM
The way you have this currently is not very practical, or up to par on coding conventions if I may point out. Arrays like that are a bit "sloppy".. Not sure about this language, but if you can you should probably just declare it as a string and index the chars individually, otherwise use the brackets { & } and have everything separated by comma.

What language is this? Right now I can only take a guess, but it would help if others knew what language you were using. This could have been VB.NET formatted in a more VB6 style... Although with the exception of these 2 lines, so i'm assuming it's some other .NET language that I haven't used yet.


input "Encrypted message:" ; encmsg$


print newmsg1$

I will say that you would only need one array for this though. (Really only one string actually.)

Cheers
~Ace



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum