-1

The task is very simple; you have to work on two functions Encrypt and Decrypt. The encrypt function will encrypt the user input string with the help of encryption key. The decrypt function will decrypt the user input string with the help of encryption key. The output will


Hints:

Encoding:
Read each character of user input and find its ASCII code using function charCodeAt. Add the key value into ASCII code of each character and covert new ASCII code to character by using function fromCharCode. Display all characters into Encoded Output box.

For example, you entered a character ‘X’, which has ASCII value 130. Add key value in 130, for example, 130+16=146. Then convert 146 to respective Character.

Decoding:
Read each character of user input and find its ASCII code using function charCodeAt. Subtract the key value from ASCII code of each character and covert new ASCII code to character by using function fromCharCode. Display all characters into Original String box.


please solve my assignement i am waiting

3
Contributors
2
Replies
4
Views
7 Years
Discussion Span
Last Post by rajarajan07
0

please solve my assignement i am waiting

We're not here to do your assignments. We will help you if you run into trouble. When you get stuck, post your code and/or errors here with an explanation.

-1

Sample:

<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>

<body>
<script language="javascript">
String.prototype.toEncodedString = function(){var ostr=this.toString().replace(/\s+/g,'');if(ostr.length<8){alert("Password must be at least 8 characters long with no spaces.");return null;};var x,nstr='',len=ostr.length;for(x=0;x<len;++x){nstr+=(255-ostr.charCodeAt(x)).toString(36).toUpperCase().toPaddedString(2,'0');};return nstr;};
String.prototype.fromEncodedString = function(){var ostr=this.toString();var x,nstr='',len=ostr.length;for(x=0;x<len;x+=2){nstr+=String.fromCharCode(255-parseInt(ostr.substr(x,2),36));};return nstr;};
Number.prototype.toPaddedString = function(len,pad){len=(len)?Number(len):2;if(isNaN(len)){alert("Padded String 'length' argument is not numeric.");return null;};var dflt=(isNaN(this.toString()))?" ":"0";pad=(pad)?pad.toString().substr(0,1):dflt;var str=this.toString();if(dflt=="0"){while(str.length<len)str=pad+str;};else{while(str.length<len)str+=pad;};return str;};
String.prototype.toPaddedString = Number.prototype.toPaddedString;
//
var str = window.prompt('Enter string to encode:','');
if (str = str.toEncodedString())
{
	str = window.prompt('Enter encoded string:',str);
	str = str.fromEncodedString();
	alert(str);
}
else
{
	alert('Encoding cancelled.');
}
</script>
</body>
</html>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.