Home > ASP Development > Pls find out the error

Pls find out the error



Dear sir
I write following functions in asp (vbscript). but when i run this page i recd blank page. Even i didnt get any error. Please help me to debug the same
--------------------------------
<%

function encryption(nSeed, sValue)
dim sNew
dim sDiv
dim sNumKey

for i = 0 To i < Len(sValue)

sDiv = ""
if(Len(sNew)> 0) then
sDiv=escape("&,&")
sNew =sNew & sDiv & Math.pow(sValue.charCodeAt(i),nSeed)
if (i = (len(sValue) -1)) then
sNew =sNew & escape("&,&") & parseInt((Math.pow(sValue.charCodeAt(i),nSeed)) & nSeed)
end if
end if
return sNew
Next
End function



function decryption(sVal)
sOutput
sTemp = unescape(sVal).split(",")

nSeed = CInt(sTemp(len(sTemp)-1) - sTemp(len(sTemp)-2))

for i = 0 To i < (len(sTemp) - 1)
sOutput = sOutput & String.fromCharCode(deRoot(sTemp(i),nSeed))
Next
return sOutput
End function

function deRoot(nValue, nSeed)
num = Round(Math.pow(nValue,(1 / nSeed)),1)
return num
End function

function Round(num, precision)
precision = 3
precision = CInt(precision)
result1 = num * Math.pow(10, precision)
result2 = Math.round(result1)
result3 = result2 / Math.pow(10, precision)
return result3
End function

function encryptME(sVal , nKey)
sEnced = encryption(parseInt(nKey), sVal)
response.write "Encoded: " & sEnced & "<BR/>"
re = decryption(sEnced)
response.write "Decoded: " & re & "<BR/>"
End function


line1="vikas"
line1=encryption(Cint(1), line1)
response.write line1

%>
-----------------------------------

same code in Javascript run properly.
Javascript code:
----------------------------------
<SCRIPT LANGUAGE="JavaScript">
<!--


function encryption(nSeed, sValue)
{

var sNew = new String();
var sDiv = new String();
var sNumKey = new Number();
for(var i = 0 ; i < sValue.length ; i++)


{
sDiv = '';
if(sNew.length > 0){sDiv=escape(',');}
sNew += sDiv + Math.pow(sValue.charCodeAt(i),nSeed)
if(i == (sValue.length -1))


{
sNew += escape(',') + parseInt((Math.pow(sValue.charCodeAt(i),nSeed)) + nSeed);
}
}


return sNew;
}

function decryption(sVal)
{
var sOutput = new String();
var sTemp = unescape(sVal).split(',');
var nSeed = new Number();
nSeed = parseInt(sTemp[sTemp.length-1] - sTemp[sTemp.length-2]);
for(var i = 0 ; i < (sTemp.length - 1) ; i++)
{
sOutput += String.fromCharCode(deRoot(sTemp[i],nSeed));
}
return sOutput;
}

function deRoot(nValue, nSeed)
{
// returns root value
var num = Round(Math.pow(nValue,(1 / nSeed)),1)
return num;
}

function Round(num, precision)
{
var precision = 3;
precision = parseInt(precision);
var result1 = num * Math.pow(10, precision);
var result2 = Math.round(result1);
var result3 = result2 / Math.pow(10, precision);
return result3;
}
//-->
</SCRIPT>
------------------------------------
Regards
vikas

    
Guest


You have several uses of javascript syntax and functions in your VBScript code which won't work. Also, your encryption() function declares a local variable, sNew, on entry, then wraps the rest of the function's code inside

Code:


if(Len(sNew)> 0) then
'
'
'
End If


so the code will never execute.

Was this answer helpful ? Yes No   
Guest
 
 
Home - About Infoqu - Contact - Privacy Statement - Link to Infoqu - Bookmark Infoqu

Copyright 2007-2008 by Infoqu. All rights reserved