Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
a basic text encryptor
Old 02-02-2009, 11:19 PM a basic text encryptor
Junior Talker

Posts: 3
Trades: 0
hi all fairly new to javascript, anyway am trying to develop an app that encrypts and decrypts text.

the idea is to encrypt only consonants based on it location within a word by assigning each letter a value (its unique key) based on its location, rather than on every occurrence of the letter within a message.

so for example in these words = Webmaster talk; for webmaster the values would be W=1, b=3, m=4, s=6, t=7, r=9 but in talk they would be t=1, l=3, k=4.

I have already sorted out the vowel script which simply goes to the next vowel based on the input key (it was a deal more simpler to think through than the consonants) and is included below just in case it has any relevance. I also set up a simple form html which inputs the text and key but not sure if you would need it.

anyway thanks in advance for any help or tips i recieve

Code:
<!-- Begin
var wt = ""; //temporary holder
var et = ""; //encoded text
var all = "";
var all2 = "";
var vowel2 = "aeiou";
var a = "a"; 
var e = "e";
var i = "i"; 
var o = "o";
var u = "u";
var vowel = new Array('a', 'e', 'i', 'o', 'u');

function encode() {
wt = "";
et = "";
all = "";
var theText = document.f1.ta1.value.toLowerCase();
var num = document.f1.tb1.value;
i2 = 0;
for (i = 0; i < num; i++) { 
i2 = i2 + 1;
if (i2 == 5) i2 = 0;
}
a = vowel[i2]; i2 = next(i2);
e = vowel[i2]; i2 = next(i2);
i = vowel[i2]; i2 = next(i2);
o = vowel[i2]; i2 = next(i2);
u = vowel[i2]; i2 = next(i2);
var all = a+e+i+o+u;
all = all.split("");
encode2(all);
}
function next(x) {
if (x == 4) x = -1;
x = x + 1;
return x;
}
function encode2(all2) {
var temp2 = document.f1.ta1.value.toLowerCase();
temp2 = temp2.split("");
var q = 0;
while (q < temp2.length) { 
wt = temp2[q];
var where = vowel2.indexOf(wt);
if (where == -1) { et += wt; }
if (where != -1) { et += all2[where]; }
q = q + 1;
}
document.f1.ta1.value = et;
}
function decode() {
wt = "";
et = "";
all = "";
all3 = "";
var theText = document.f1.ta1.value.toLowerCase();
var num = document.f1.tb1.value;
i2 = 0;
for (i = 0; i < num; i++) {
i2 = i2 + 1;
if (i2 == 5) i2 = 0;
}
a = vowel[i2]; i2 = next(i2);
e = vowel[i2]; i2 = next(i2);
i = vowel[i2]; i2 = next(i2);
o = vowel[i2]; i2 = next(i2);
u = vowel[i2]; i2 = next(i2);
var all = a+e+i+o+u;
all3 = all;
all = all.split("");
decode2(all3);
}
function decode2(all2) { 
var vowel2 = "aeiou";
vowel2 = vowel2.split("");
var temp2 = document.f1.ta1.value.toLowerCase();
temp2 = temp2.split("");
var v = 0;
while (v < temp2.length) {
wt = temp2[v];
var where = all2.indexOf(wt);
if (where == -1) { et += wt; }
if (where != -1) { et += vowel2[where]; }
v = v + 1;
}
document.f1.ta1.value = et;
}
//  End -->
jason.claude is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-03-2009, 07:27 AM Re: a basic text encryptor
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
You do realise that anything to do with javascript is visible to everyone, which makes any javascript encryption useless for anything more than a programming exercise.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 02-03-2009, 09:03 PM Re: a basic text encryptor
Junior Talker

Posts: 3
Trades: 0
Should I try php then, the only reason i chose javascript was because it meant that I would not need to install php and apache to test the script.
jason.claude is offline
Reply With Quote
View Public Profile
 
Old 02-03-2009, 09:23 PM Re: a basic text encryptor
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Any server side code will be preferable.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 02-04-2009, 09:42 AM Re: a basic text encryptor
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Besides, JavaScript just isn't fast enough to make the kind of efficient calculations needed to make really good encryption work.

I've put together something with PHP, however, that I'm really proud of. It's my baby. HINT: it helps to know a little bit about hexidecimal numbers.
__________________
Join me on
Please login or register to view this content. Registration is FREE
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 02-04-2009, 10:53 PM Re: a basic text encryptor
Junior Talker

Posts: 3
Trades: 0
thanks will start on a php version then
jason.claude is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to a basic text encryptor
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.22617 seconds with 12 queries