Jump to content

Any javascript gurus out there?


Redcap

Recommended Posts

First off, I'm not a programmer - programming is an arcane art to me, and more akin to magic, plus when it comes to maths, I have trouble balancing my cheque book!

 

OK, it's a simple enough problem. I want to re-order the alphabet (ABCDEFGHIJKLMNOPQRSTUVWXYZ) randomly, as many times as possible, without repeating any letters in each re-ordering. Example: HCLMNORSBJQTAUGVPEXDKIWYZF.

 

It's for a simple substitution cipher (don't ask - it's a silly reason why, but amusing, none the less!), but I'm buggered if I'll do it manually, so need a script that I can run in my browser locally, off line.

 

I've found one site that does it to a point (http://www.unitedscripters.com/scripts/crypto3.html), called 'lucifer', and lists the script, but this repeats the randomisations after 23 strings, so isn't much use (I need a hell of a lot more strings than 23!); I also found a one-time pad generator (at http://www.fourmilab.ch/onetime/otpjs.html), but it repeats letters like crazy, so isn't any use as a simple substitution cipher key.

 

Now, I understand the principle (you randomise the alphabet pretty much ad infinitum), but writing the script has completely defeated me (read the first paragraph of this post :blink: ).

 

Following something like 8 hours of trawling the net on dial-up on this problem, my eyes are going screwy, as you can imagine. So: Can anyone come up with a script for me?

 

Many thanks in advance!

 

Roger

Link to post
Share on other sites

I'm no Javascript Guru, but I have dabbled on occasion ;)

 

What you want to do would be most easily done with a couple of arrays and a variable. In case you don't know, Arrays are like variables (storage boxes for bits of data), but unlike variables, arrays have lots of seperate compartments that can each store different data values.

  • e.g. A variable could hold my full name. An array could hold the full names of up to about 32,000 people). All you have to do to use it is select the compartment (or index) and then either read what is stored there, or write new data to it.

Some good javascript resources include...

 

http://www.javascript.com

http://java.internet.com/

http://www.webreference.com/programming/javascript/forms

 

...and quite a few others.

 

Some have tutorials, but these vary in quality. My advice is to search through the scripts they have for download for some suitable donor code. You are looking for a script that uses arrays to sort, randomise, and divide variables in to their component parts. Date scripts often do some variable division (splitting long variables up in to individual characters for analisys). Sorting is often done by financial and mathematical scripts. Password scripts will show you how to compare variables (and multi-user password scripts often make good use of arrays). Randomising can be found in a lot of scripts. The best ones are often scripts to redirect web-page banner clicks randomly, and games of chance.

 

Good luck ;)

Link to post
Share on other sites

Happy New Year to you too. :)

 

One thought is that you might want to duplicate your initial post here, on a Javascript forum (there are a few about), and see what others come back to you with. Chances are you'll be posting in Guru-City, so someone may well come back and give you a link to a perfectly working script.

 

Good luck ;)

Link to post
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and the use of session cookies.