Click to See Complete Forum and Search --> : Programming challenge...


AdamBrill
11-26-2003, 10:22 PM
Hey guys!

I've been wanting to start a challenge for a while, so here it finally is. ;) Here are some generic rules for the challenges:

Rules:

#1. You cannot get off-topic. If you do get off-topic, your entry will be removed from the challenge and you will be warned. If you are a repeat offender, you may get banned from all challenges.

#2. You cannot post the answer or any hints on the forums until told to do so. If you do, your entry will be removed from the challenge and you will be warned. Once again, if you are a repeat offender, you may get banned from all challenges.

#3. You cannot get help from anywhere; you must solve/complete the challenges yourself. If you are caught cheating, you will probably be banned from all challenges.

#4. You must follow all rules given in the challenge.

And here is the first challenge:

It's called Break the Security! :D

Here is the encrypted string(all supposed to be on one line):

0582062206220611054306300622062506180557054305950615061606260543061606260543062706150612054306260627 062506160621061405430627061506080627054306300608062605430612062106100625063206230627061206110557


And here is the encrypting/decrypting functions:

function create_pass(pass){
return pass.charCodeAt(0)+pass.charCodeAt(1)+pass.charCodeAt(2)+pass.charCodeAt(3)+pass.charCodeAt(4);
}
function encrypt(text,pass){
pass = create_pass(pass);
str = "";
for(x=0; x<text.length; x++){
add = "";
code = text.charCodeAt(x);
code += pass;
for(y=0; y<4-String(code).length; y++){
add += "0";
}
add += code;
str += add;
}
return str;
}
function decrypt(text,pass){
pass = create_pass(pass);
text_array = new Array();
while(text.length > 0){
text_array[text_array.length] = Number(text.substring(0,4)-pass);
text = text.substring(4);
}
str = "";
for(x=0; x<text_array.length; x++){
str += String.fromCharCode(text_array[x]);
}
return str;
}

Goal:

Break the security and tell me what the unencrypted string is. You will get extra points for telling me what the password that I used was.

It is extremely simple, but I figured I should make the first one pretty easy. ;) So, good luck, guys. And remember rule #2... :)

If you figure it out, PM me the answer...

EDIT: Change of plans. The first person to come up with the correct answer wins. If you come up with the correct decrypted string AND a password to fit, post it on here and you won... Do not post only the string; you must have both the decrypted string and a password before posting your answer.

EDIT #2: Since it was pointed out to me that there are multiple passwords that will work for this, you only need to come up with one password that will work, not necessarily my password.

AdamGundry
11-27-2003, 11:58 AM
Got it: "Good work. This is the string that was encrypted."

The first password I found was "fIlrr", but there are others (for example, "o_e`l").

In case you are interested, here is the code I used:

for (var k=0;k<100;k++){
p = gen_pass();
document.writeln(p + ' --- ' + decrypt('0582062206220611054306300622062506180557054305950615061606260543061606260543062706150612054 3062606270625061606210614054306270615060806270543063006080626054306120621061006250632062306270612061 10557', p));
}

function gen_pass(){
var s = '';
for (var l=0;l<5;l++){
s += String.fromCharCode(Math.random()*57 + 65);
}
return s;
}

Adam

AdamBrill
11-27-2003, 01:10 PM
Good job, Adam. Jeff Mott also came up with the answer, but he PMed me rather than posting(since I had asked for the password that I used and he knew that he couldn't get the same one that I used). That is why I edited my post adding the second edit. I figured Jeff would come on right away and post, but he must not have been on... So, I guess this is going to have to be a tie. :D

I want this to just keep going(one contest/challenge after another), so if either of you want to start one, go ahead. It doesn't have to be anything to do with encryption, just as long as it has something to do with programming. ;) If neither of you want to, I'll come up with another one in a day or two...

AdamGundry
11-27-2003, 02:18 PM
Sounds like Jeff beat me, since I didn't crack it until after you posted the second edit. Oh well.

I like the idea of keeping this going, and I'll try to come up with something. :)

Adam

Jeff Mott
11-27-2003, 08:46 PM
I figured Jeff would come on right away and post, but he must not have been on...Yes, Thanksgiving and such... ;)

If anyone's interested, I had run a frequency analysis to find the most common occuring number set, which is 0543. Generated the pass number under the assumption that 0543 represented a space (the most common occuring character for plain text on a computer) and that did it.

AdamBrill
11-27-2003, 09:10 PM
Originally posted by Jeff Mott
If anyone's interested, I had run a frequency analysis to find the most common occuring number set, which is 0543. Generated the pass number under the assumption that 0543 represented a space (the most common occuring character for plain text on a computer) and that did it. lol... You out did yourself there, Jeff. :p It really didn't need anything that complex to break it. ;)

I find it quite humorous that you would choose that route to break it. :D

Jeff Mott
11-27-2003, 10:00 PM
Well I had already written the code for a frequency analysis (which really isn't very complicated at all) some time ago. It was quicker just to run that than it was to brute force the passwords.