Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Need to speed up a decryption program.

Author
Message
Tim Ballisto
21
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Right behind you.
Posted: 19th Sep 2004 06:51 Edited at: 19th Sep 2004 06:54
In a simple cypher, where each letter represents another letter, devoid of cases and numerals, there are 26^26 possible keys. This is heck for the computer to handle. I have enclosed the current code, but i need a way to cut down the loops.



My theory is that you could input the screening between the loops, and that could cut it down by a lot.

I just figured out that the nexts in the for-next loops are backwards, fixing it now.


Programs for programmers.
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 19th Sep 2004 07:22
Well first off, you need to change your method. You say you're using a simple cypher but what you have allowed up in that code is that any character can be any other character at any other time. This means that variables B and C can both be the letter "A" at the same time in the decoded message, something the alphabet substition method does not allow.

Second, using for-nexts for this process is very slow anyway, you should be using an array instead. That way, you fill an array with the letters A to Z and then use the ascii value of each message letter to point into the array to retrieve the (hopefully) decoded text. Then all you have to do is "swap" two letters in the array, say making array(1) equal to "B" and array(2) equal to "A". Then display the message again, using te new letter substitions.

Finally, for a normal decryption process you'd have "limits" on what the letters could be, an array to say "this letter is locked so don't swap it again" which the user, or the program can generate. (For example, a letter standing alone by itself is most likely an I or A in english text and once determined, it need never be change again in the decoding.)

Anyway, those are my thoughts on the matter. I believe you'd find the result running a lot faster if you tried things this way...
Good luck,
S.

Any truly great code should be indisguishable from magic.

Login to post a reply

Server time is: 2025-05-24 16:53:46
Your offset time is: 2025-05-24 16:53:46