Home
Miscellaneous
Matts Encrypter
This script will encrypt any text including HTML into an almost impossible-to-crack binary sequence.
Matts Encrypter
Encrypting Text Example
Enter some text in the top box, click Encrypt and get the encrypted result in the lower box.
To decrypt, enter the encrypted text in the lower box and click Decrypt .
© Matthew Tong 2002
The JavaScript Source: Miscellaneous: Matts Encrypter
Simply click inside the window below, use your cursor to highlight the script, and copy (type Control-c or Apple-c) the script into a new file in your text editor (such as Note Pad or Simple Text) and save (Control-s or Command-s). The script is yours!!!
<!-- ONE STEP TO INSTALL MATTS ENCRYPTER:
1. Copy the coding into the BODY of your HTML document -->
<!-- STEP ONE: Paste this code into the BODY of your HTML document -->
<BODY>
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Original: Matthew Tong (phreeeky@hotmail.com ) -->
<!-- Web Site: http://phreeeky.dk3.com -->
<center>
<table border=1 bordercolor=black cellpadding=5 cellspacing=0 width=560>
<tr><td valign=center align=center style="height:40px; background:#888888; color:#ffffff;">
<b>Matts Encrypter</b>
</td></tr>
<tr><td valign=center align=center style="height:30px; background:#dedede;">
Encrypting Text Example
</td></tr>
<tr><td valign=center align=left>
<br>
Enter some text in the top box, click <i>Encrypt</i> and get the encrypted result in the lower box.
<br><br>
To decrypt, enter the encrypted text in the lower box and click <i>Decrypt</i>.
<br><br
</td></tr>
<form name="enc_form">
<tr><td valign=center align=left style="height:20px; background:#cccccc;">
<table width="100%" border=0 cellpadding=0 cellspacing=0>
<tr><td valign=center align=left>
Decrypted Text:
</td><td valign=center align=right style="height:20px; background:#cccccc;">
<a href="javascript: encrypt();">Encrypt</a>
</td></tr>
</table>
</td></tr>
<tr><td valign=center align=center>
<br>
<textarea name="decrypted" cols=60 rows=10></textarea>
<br><br>
</td></tr>
<tr><td valign=center align=left style="height:20px; background:#cccccc;">
<table width="100%" border=0 cellpadding=0 cellspacing=0>
<tr><td valign=center align=left>
Encrypted Text:
</td><td valign=center align=right style="height:20px; background:#cccccc;">
<a href="javascript: decrypt();">Decrypt</a>
</td></tr>
</table>
</td></tr>
<tr><td valign=center align=center>
<br>
<textarea name="encrypted" cols=60 rows=10></textarea>
<br><br>
</td></tr>
</form>
<script>
<!--
// Add or remove characters to 'alphabet' in the same way as shown.
// Any characters not in alphabet will be ignored when encrypting.
alphabet = new Array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','1','2','3','4','5','6','7','8','9','0','(',')','~','!','@','#','$','%','^','&','*','-','=','+','_','.',',','`','{','}','[',']','|','\'','\\','\"','/','?',':',';','>','<',' ','\n');
// Temporary array for when producing binary numbers. Longer length = better encryption.
// Note: the max binary number must be more than the alphabet length.
// there must be an 'a' at the end of the array.
tempbin = new Array("0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","a");
// Binary numbers stored here and refer to original alphabet.
binary = new Array();
// Variables for the jumbled(encrypted) alphabet, decrypted text, and encrypted text.
var encalphabet;
var decrypted;
var encrypted;
// function to make the binary numbers
// l = current position
// len = binary number length
// z = current number
// The rest is straight forward - figure it out for your self.
function makebinary(l,start,z) {
if (l < 0)
return;
if (tempbin[l] == "1") {
tempbin[l] = "0";
x = makebinary(l-1,start,z);
}else if (tempbin[l] == "0"){
tempbin[l] = "1";
}else if (tempbin[l] == "a"){
tempbin[l] = "0";
}
if (l == start) {
binary[z] = "";
for (i = 0; i <= l; i++)
binary[z] += tempbin[i];
}
return;
}
// Calls makebinary() to make enough numbers for all of alphabet.
for (z = 0; z < alphabet.length; z++) {
makebinary(tempbin.length-1,tempbin.length-1,z);
}
// Checks to see if a letter (alphabet[x]) is in encalphabet so there are no duplicates in encalphabet.
function in_encalphabet(x) {
if (x == -1)
return 0;
z = alphabet[x];
for (i = 0; i < encalphabet.length; i++) {
if (z == encalphabet.substr(i,1))
return 0;
}
return 1;
}
// Encrypt function (well duh!!)
function encrypt() {
// Set start values
decrypted = document.enc_form.decrypted.value;
encalphabet = "";
encrypted = "";
// Make encalphabet (ie. jumble alphabet)
for (i = 0; i < alphabet.length; i++) {
x = -1;
while (in_encalphabet(x) == 0)
x = Math.floor(alphabet.length*Math.random());
encalphabet += alphabet[x];
}
temp = encalphabet;
// First level of encryption.
// Uses encalphabet's order to jumble text.
for (i = 0; i < decrypted.length; i++) {
for (z = 0; z < encalphabet.length; z++) {
if (decrypted.substr(i,1) == alphabet[z]) {
temp += encalphabet.substr(z,1);
break;
}
}
}
// Second level of encryption.
// Sets everything into binary.
for (i = 0; i < temp.length; i++) {
for (z = 0; z < alphabet.length; z++) {
if (temp.substr(i,1) == alphabet[z]) {
encrypted += binary[z];
break;
}
}
}
// Display encrypted text.
document.enc_form.encrypted.value = encrypted;
}
// This is obviously the decryption function.
function decrypt() {
// Set initial values.
encrypted = document.enc_form.encrypted.value;
encalphabet = "";
temp = "";
decrypted = "";
// Go from binary to first level encryption (ie. Still jumbled).
for (i = 0; i < encrypted.length; i+=tempbin.length) {
for (z = 0; z < alphabet.length; z++) {
if (encrypted.substr(i,tempbin.length) == binary[z]) {
temp += alphabet[z];
break;
}
}
}
// Set the order of the alphabet (into encalphabet) from jumbled text.
for (i = 0; i < alphabet.length; i++)
encalphabet += temp.substr(i,1);
// Unjumble the text.
while (i < encrypted.length) {
for (z = 0; z < encalphabet.length; z++) {
if (temp.substr(i,1) == encalphabet.substr(z,1)) {
decrypted += alphabet[z];
break;
}
}
i++;
}
// Display the decrypted text.
document.enc_form.decrypted.value = decrypted;
}
//-->
</script>
<tr><td valign=center align=center style="height:30px; background:#dedede;">
© Matthew Tong 2002
</td></tr>
</table>
</center>
<p><center>
<font face="arial, helvetica" size"-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>
<!-- Script Size: 6.67 KB --> Did you use this script? Do you like this site? Please link to us!
Comments feed