...

View Full Version : Think Any Of You Can Code This? Plz Try



MistaaKay
07-24-2012, 10:57 PM
I am really bad at coding. but i have invented a Cyphyr.
I REALLY want this into a Encoding/Decoding program for me and my cousin.
I will explain the Cyphyr bellow. and if ANYONE is up to the task of making it a program..
PLEASE DO!!
(i understand what i am asking of you is alot.. well atleast i think it is. maybe it'll take you guys like 2 minutes... i dont know)
----------------------------------------------------------
input a date: 24/08/1988
the code is: 24081988

message: this is magical

--"x"s are spaces

thisxisxmagical

--then you loop the code over top of the letters in the encryption


2 4 0 8 1 9 8 8 2 4 0 8 1 9 8 8
t h i s x i s x m a g i c a l

--then you use this data to move forward in the alphabet

T: abcdefghijklmnopqrstuvwxyz
--move forward 2 letters from "T" , so "V"

H: abcdefghijklmnopqrstuvwxyz
--move forward 4 letters from "H" , so "L"

I: abcdefghijklmnopqrstuvwxyz
--move forward 0 letters from "I" , so "I"

ect.


--and eventually you have the encryption:

VLIAYRAFOEGQDJT


--then reverse all of these for the decryption:


VLIAYRAFOEGQDJT

2 4 0 8 1 9 8 8 2 4 0 8 1 9 8 8
V L I A Y R A F O E G Q D J T

--then you use this data to move backwards in the alphabet

V: abcdefghijklmnopqrstuvwxyz
--move backwards 2 letters from "V" , so "T"

ect.

---------------------------------------------------------

So if any coder is up to the task please make my Cyphyr into a Encrypting/Decrypting program
Ty!
:D

jmrker
07-25-2012, 12:20 AM
Read post #3 of sticky #4 ( http://www.codingforums.com/showthread.php?t=2090 )

At least make ANY attempt!

Old Pedant
07-25-2012, 12:30 AM
That's about as strong a cipher as wet tissue paper. Most hackers could decode it in minutes.

Plus, if you do the encoding in JavaScript in the browser, anybody can simply look at the code and figure out almost instantly what you are doing.

But...

The code is trivial.



var alphabet = "abcdefghijklmnopqrstuvwxyz";
var message = "your message";
var key = "24081988";

var result = "";
for ( var m = 0; m < message.length; ++m )
{
var ch = message.charAt(m).toLowerCase();
var chnum = alphabet.indexOf(ch);
if ( chnum < 0 )
{
// used a character not in the alphabet
// what do you want to do with it?
result += ch; // just put it in the result?
} else {
var koff = Number( key.charAt(m % key.length) );
result +=alphabet.charAt( ( chnum + koff ) % alphabet.length );
}
}
alert( result );

You should consider making your alphabet contain space, numbers, symbols, upper and lower case, etc. It would be (very mildly) more effective.

I'll let you work out the decrypting code. Just one small part of one line needs to be changed.

MistaaKay
07-25-2012, 01:39 AM
That's about as strong a cipher as wet tissue paper. Most hackers could decode it in minutes.

Plus, if you do the encoding in JavaScript in the browser, anybody can simply look at the code and figure out almost instantly what you are doing.

But...

The code is trivial.



var alphabet = "abcdefghijklmnopqrstuvwxyz";
var message = "your message";
var key = "24081988";

var result = "";
for ( var m = 0; m < message.length; ++m )
{
var ch = message.charAt(m).toLowerCase();
var chnum = alphabet.indexOf(ch);
if ( chnum < 0 )
{
// used a character not in the alphabet
// what do you want to do with it?
result += ch; // just put it in the result?
} else {
var koff = Number( key.charAt(m % key.length) );
result +=alphabet.charAt( ( chnum + koff ) % alphabet.length );
}
}
alert( result );

You should consider making your alphabet contain space, numbers, symbols, upper and lower case, etc. It would be (very mildly) more effective.

I'll let you work out the decrypting code. Just one small part of one line needs to be changed.

I was thinking of maybe this?:

1qaz2wsx3edc4rfv5tgb6yhn7ujm8ik,9ol.0p;/

its like going diagonal from the num line of the keyboard to the bottom most character.

do you think that would make it any more secure?? btw, thanks for the quick reply! :)

Old Pedant
07-25-2012, 01:52 AM
No. So long as the code is sitting there in JavaScript for anybody to see, it is not secure. Period.

If you want secure encryption, you need to do it on the server (e.g., in PHP/ASP/JSP code). And you need a heluva lot better algorithm than that one.

MistaaKay
07-25-2012, 02:36 AM
hmm..... im not that advanced so i have no idea what that is supposed to mean. but don't servers cost money?

MistaaKay
07-25-2012, 02:51 AM
Also im a mega newb and i was wondering if you could make the code into an .exe

i frankly have no idea how to test the code... ;P

I would really appreciate it

Old Pedant
07-25-2012, 02:52 AM
$5 a month. Or even less for some.

Shared server. Example: GoDaddy.com but there are many others.

Lerura
07-25-2012, 03:19 AM
hmm..... im not that advanced so i have no idea what that is supposed to mean. but don't servers cost money?

Not necessarily!
The server is the computer where the document is stored, which can be the computer that you are sitting by right now.
Though you wil have to install the server-side languages on the computer in order to use them.
--------
One of the difference between server-side language and client-side languages is that the source of client-side coding is accessible for all to see, while you cannot access the source of server-side coding. Here you only see the result.

In other words:
With client-side coding you can see every step taken towards the final result, and thus you are able to reverse every step, to get back to the original unencrypted data. It is just a matter of time, will, and sense of logic

With server-side coding you will only see the result. Every step from the original code will be hidden to the viewer, thus they cannot know what steps has been taken, which mean that they can't reverse it.

MistaaKay
07-25-2012, 05:59 AM
Not necessarily!
The server is the computer where the document is stored, which can be the computer that you are sitting by right now.
Though you wil have to install the server-side languages on the computer in order to use them.
--------
One of the difference between server-side language and client-side languages is that the source of client-side coding is accessible for all to see, while you cannot access the source of server-side coding. Here you only see the result.

In other words:
With client-side coding you can see every step taken towards the final result, and thus you are able to reverse every step, to get back to the original unencrypted data. It is just a matter of time, will, and sense of logic

With server-side coding you will only see the result. Every step from the original code will be hidden to the viewer, thus they cannot know what steps has been taken, which mean that they can't reverse it.


$5 a month. Or even less for some.

Shared server. Example: GoDaddy.com but there are many others.


hey guys... im not looking for maximum security encrypting here. just as much as i need to have secret / private conversations :P

can you make the code into a .exe for me please? i have no idea how to do that and i cannot test the program to see how it is ;/ sorry for being Ultra Newb

jmrker
07-25-2012, 04:04 PM
There is no .exe file to create.

Save a text file (Old Pedant's example in post #3) with an .html extension.
Note: Be sure to surround his example with <script type='text/javascript"> </script> tags.

Open that file on your computer with a browser 'open file' action.

MistaaKay
07-25-2012, 04:28 PM
There is no .exe file to create.

Save a text file (Old Pedant's example in post #3) with an .html extension.
Note: Be sure to surround his example with <script type='text/javascript"> </script> tags.

Open that file on your computer with a browser 'open file' action.

It doesnt do anything :/

just a blank screen...

i surrounded it with the tags and i saved it as a .html

Old Pedant
07-25-2012, 10:15 PM
*sigh*

Okay...here you go...


<html>
<head>
<title>Uncle Billy's Magic Two Way Decoder Ring</title>
</head>
<body>
<h2>Don't forget to eat your cereal!</h2>
<br/><br/>
<form id="theForm">
Message: <input name="msg" size="60"/>
<br/>
Key: <input name="usekey" size="10" />
<br/>
Encoded: <input name="coded" size="60"/>
<br/>
<input type="button" name="encode" value="Encode"/>
<input type="button" name="decode" value="Decode"/>
</form>

<script type="text/javascript">

var alphabet =
"WX;#!Q,:S&TYZhR%$U0<+k>n-V[i.j()l ?1]*=362mcdHACG_EsIJ4Kp^9@MNBOq5PeortLb7xa8{|Dgf}Fyuvwz~";

var form = document.getElementById("theForm");

function encodeDecode( sFrom, mult )
{
var key = form.usekey.value;
var result = "";
for ( var m = 0; m < sFrom.length; ++m )
{
var ch = sFrom.charAt(m);
var chnum = alphabet.indexOf(ch);
if ( chnum < 0 )
{
// used a character not in the alphabet
// what do you want to do with it?
result += ch; // just put it in the result?
} else {
var koff = Number( key.charAt(m % key.length) );
// var koff = alphabet.indexOf( key.charAt(m % key.length) );
var c = ( chnum + alphabet.length + mult * koff ) % alphabet.length;
result += alphabet.charAt( c );
}
}
return result;
}

form.encode.onclick =
function()
{
form.coded.value = encodeDecode( form.msg.value, 1 );
};

form.decode.onclick =
function()
{
form.msg.value = encodeDecode( form.coded.value, -1 );
};
</script>
</body>
</html>

If you replace the line in blue with the line in red (after removing the // from the front), then you can use any WORD or words as the key, instead of having to use a number. (As written, the key must be a number.)

Old Pedant
07-25-2012, 10:18 PM
If it's not obvious:

To encode a message, type it into the first text box. Type your key (must be all digits unless you make the change I indicated) into the second text box. Press the Encode button.

To decode a message, type the coded message into the THIRD text box. Type your key (must be all digits unless you make the change I indicated) into the second text box. Press the Decode button.

MistaaKay
07-26-2012, 03:00 AM
if it's not obvious:

To encode a message, type it into the first text box. Type your key (must be all digits unless you make the change i indicated) into the second text box. Press the encode button.

To decode a message, type the coded message into the third text box. Type your key (must be all digits unless you make the change i indicated) into the second text box. Press the decode button.

thank you you f*%king boss! :D

loveee youuuuuuuu (all homo!)

i "Thanked" you and +Rep'ed you!

MistaaKay
07-26-2012, 03:50 AM
If it's not obvious:

To encode a message, type it into the first text box. Type your key (must be all digits unless you make the change I indicated) into the second text box. Press the Encode button.

To decode a message, type the coded message into the THIRD text box. Type your key (must be all digits unless you make the change I indicated) into the second text box. Press the Decode button.


One LAST question.... how can i replace every " " (space) with a "x"
??

Old Pedant
07-26-2012, 04:17 AM
One LAST question.... how can i replace every " " (space) with a "x"
??

Why would you want to? In my code, spaces are encoded into who knows what. And it's legit for a space to appear in the encoded result, too.

If you look carefully, you'll find there is a space in my "alphabet". It's just before the question mark.

Anyway, if you are going to replace space with something, don't use x. Use something more obscure.

If you want to do this, remove the space from the alphabet and then change the two functions, thus:


form.encode.onclick =
function()
{
var text = form.msg.value.replace(" ","~");
form.coded.value = encodeDecode( form.msg.value, 1 );
};

form.decode.onclick =
function()
{
var text = encodeDecode( form.coded.value, -1 );
form.msg.value = text.replace("~"," ");
};

I chose ~ as the replacement for space, as it's really unlikely to be used in an English language message.

By the by, if you use the version that allows any text at all as the key, it will take anybody trying to break the code much longer than if you just use digits. A bit over 6 times as long, on average.

Old Pedant
07-26-2012, 04:21 AM
By the way, if you used a <textarea> to enter the message and encoded message text, then any line breaks in the message would be preserved, as is. That's because only ASCII "printable" characters (with or without space, as you decide) are encoded.

So it would allow you to create much longer messages, if you wanted to.

jmrker
07-26-2012, 05:33 AM
One LAST question.... how can i replace every " " (space) with a "x"
??

Then how would you encrypt/decrypt words like?
Xylophone
X-ray
Exxon
Xerox



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum