Go Back   CodingForums.com > :: Computing & Sciences > Computer Programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-12-2013, 05:13 PM   PM User | #1
KashSmith100001
New to the CF scene

 
Join Date: Dec 2012
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
KashSmith100001 is an unknown quantity at this point
Ceasar Cipher Cracker, having problems

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!)

Code:
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 is offline   Reply With Quote
Old 01-12-2013, 05:23 PM   PM User | #2
KashSmith100001
New to the CF scene

 
Join Date: Dec 2012
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
KashSmith100001 is an unknown quantity at this point
Thanks, but I finally figured it out.
KashSmith100001 is offline   Reply With Quote
Old 01-12-2013, 05:24 PM   PM User | #3
KashSmith100001
New to the CF scene

 
Join Date: Dec 2012
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
KashSmith100001 is an unknown quantity at this point
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.
KashSmith100001 is offline   Reply With Quote
Old 01-12-2013, 07:23 PM   PM User | #4
Redcoder
Regular Coder

 
Redcoder's Avatar
 
Join Date: May 2012
Location: /dev/couch
Posts: 309
Thanks: 2
Thanked 46 Times in 45 Posts
Redcoder has a little shameless behaviour in the past
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.
__________________
For professional Hosting and Web design.....


NetEssentials.co.uk
Redcoder is offline   Reply With Quote
Old 01-20-2013, 02:22 PM   PM User | #5
AceInfinity
New Coder

 
Join Date: Jan 2013
Location: Canada
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
AceInfinity is an unknown quantity at this point
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.

Code:
input "Encrypted message:" ; encmsg$
Code:
print newmsg1$
I will say that you would only need one array for this though. (Really only one string actually.)

Cheers
~Ace

Last edited by AceInfinity; 01-20-2013 at 02:24 PM..
AceInfinity is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:23 AM.


Advertisement
Log in to turn off these ads.