Home > jQuery > Javascript Encrypt Decrypt

Javascript Encrypt Decrypt

I am going to demonstrate a simple encryption/decryption mechanism using JavaScript.

function Encrypt()
{
    var actual = "stringtoencrypt";
    var key = 100; //Any integer value
    var result = "";
    for(i=0; i<actual.length;i++)
    {
        result += String.fromCharCode(key^actual.charCodeAt(i));
    }
    alert(result);
}

function Decrypt()
{
    var actual="encryptedstring";
    var key = 100; //Any integer value
    var result="";    
    for(i=0; i<actual.length; i++)
    {
        result += String.fromCharCode(key^actual.charCodeAt(i));
    }
}

Note – People can view source and find out the real value. This example was created just for demonstration

Advertisements
Categories: jQuery
  1. Ragunathan
    November 21, 2013 at 11:04 AM

    Thanks.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: