QN: Write a program that inputs an encrypted four-digit integer and decrypts it to form the original number.
CODE:
<html>
<head>
<title>q15</title>
<script>
function f1()
{
var a;
var array={};
a=document.getElementById("t1").value;
if(a>999 && a<10000)
{
for(var i=0;i<a.length;i++)
{
if(a[i]==0)
document.writeln("m");
else if(a[i]==1)
document.writeln("a");
else if(a[i]==2)
document.writeln("u");
else if(a[i]==3)
document.writeln("p");
else if(a[i]==4)
document.writeln("e");
else if(a[i]==5)
document.writeln("o");
else if(a[i]==6)
document.writeln("w");
else if(a[i]==7)
document.writeln("t");
else if(a[i]==8)
document.writeln("b");
else if(a[i]==9)
document.writeln("k");}
}
else
alert("input valid nnumber");
}
function f2()
{
var a;
var array={};
a=document.getElementById("t1").value;
{
for(var i=0;i<a.length;i++)
{
if(a[i]=='m')
document.writeln("0");
else if(a[i]=='a')
document.writeln("1");
else if(a[i]=='u')
document.writeln("2");
else if(a[i]=='p')
document.writeln("3");
else if(a[i]=='e')
document.writeln("4");
else if(a[i]=='o')
document.writeln("5");
else if(a[i]=='w')
document.writeln("6");
else if(a[i]=='t')
document.writeln("7");
else if(a[i]=='b')
document.writeln("8");
else if(a[i]=='k')
document.writeln("9");
}
}
}
</script>
</head>
<body>
<label>number</label>
<input type="text" name="" value="" id="t1" />
<input type="submit" value="to encrypt" onclick="f1()" />
<input type="submit" value="to decrypt" onclick="f2()"/>
</body>
</html>
OUTPUT:-
CODE:
<html>
<head>
<title>q15</title>
<script>
function f1()
{
var a;
var array={};
a=document.getElementById("t1").value;
if(a>999 && a<10000)
{
for(var i=0;i<a.length;i++)
{
if(a[i]==0)
document.writeln("m");
else if(a[i]==1)
document.writeln("a");
else if(a[i]==2)
document.writeln("u");
else if(a[i]==3)
document.writeln("p");
else if(a[i]==4)
document.writeln("e");
else if(a[i]==5)
document.writeln("o");
else if(a[i]==6)
document.writeln("w");
else if(a[i]==7)
document.writeln("t");
else if(a[i]==8)
document.writeln("b");
else if(a[i]==9)
document.writeln("k");}
}
else
alert("input valid nnumber");
}
function f2()
{
var a;
var array={};
a=document.getElementById("t1").value;
{
for(var i=0;i<a.length;i++)
{
if(a[i]=='m')
document.writeln("0");
else if(a[i]=='a')
document.writeln("1");
else if(a[i]=='u')
document.writeln("2");
else if(a[i]=='p')
document.writeln("3");
else if(a[i]=='e')
document.writeln("4");
else if(a[i]=='o')
document.writeln("5");
else if(a[i]=='w')
document.writeln("6");
else if(a[i]=='t')
document.writeln("7");
else if(a[i]=='b')
document.writeln("8");
else if(a[i]=='k')
document.writeln("9");
}
}
}
</script>
</head>
<body>
<label>number</label>
<input type="text" name="" value="" id="t1" />
<input type="submit" value="to encrypt" onclick="f1()" />
<input type="submit" value="to decrypt" onclick="f2()"/>
</body>
</html>
OUTPUT:-
0 Comments: