I have some code I inherited for an encryption which we where running in asp. We now need to convert it to VB.Net but unfortunately its a mix of asp and javascript
The code was originally
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Function IzDecrypt(ByVal s)
Dim k, x, iKeyChar, iStringChar, iDeCryptChar
k = ReadKeyFromFile()
x = ""
For i = 1 To len(s)
iKeyChar = mid(k, i, 1)
iStringChar = mid(s, i, 1)
iDeCryptChar = expon(iKeyChar, iStringChar)
x = x & iDeCryptChar
Next
IzDecrypt = x
End Function
</SCRIPT>
<script language=JavaScript RUNAT=SERVER>
function expon(a,b) {
return (String.fromCharCode(a.charCodeAt(0) ^ b.charCodeAt(0)));
}
</script>
run inside the global.asa.
I now need to integrate this into the global.asax, but am unsure how (and if I can) integrate the javascript part as the asp and javascript need to communicate
For asp.net now have:
----------------------------------------------------------
Imports System.Web
Imports System.Web.SessionState
Public Class Global
Inherits System.Web.HttpApplication
Function IzDecrypt(ByVal s)
Dim k, x, iKeyChar, iStringChar, iDeCryptChar
k = ReadKeyFromFile()
x = ""
For i = 1 To len(s)
iKeyChar = mid(k, i, 1)
iStringChar = mid(s, i, 1)
iDeCryptChar = expon(iKeyChar, iStringChar)
x = x & iDeCryptChar
Next
IzDecrypt = x
End Function
End Class
-----------------------------------------------------------
but cannot see how I can add the javascript runat server bit so that the asp.net knows about the expon function. (Assume if I change languages this could affect the expon functionality so cannot simply change to asp.net). Can anyone give me suggestions as to whether this is feasible and if so any pointers
Thanks
Andy
The code was originally
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Function IzDecrypt(ByVal s)
Dim k, x, iKeyChar, iStringChar, iDeCryptChar
k = ReadKeyFromFile()
x = ""
For i = 1 To len(s)
iKeyChar = mid(k, i, 1)
iStringChar = mid(s, i, 1)
iDeCryptChar = expon(iKeyChar, iStringChar)
x = x & iDeCryptChar
Next
IzDecrypt = x
End Function
</SCRIPT>
<script language=JavaScript RUNAT=SERVER>
function expon(a,b) {
return (String.fromCharCode(a.charCodeAt(0) ^ b.charCodeAt(0)));
}
</script>
run inside the global.asa.
I now need to integrate this into the global.asax, but am unsure how (and if I can) integrate the javascript part as the asp and javascript need to communicate
For asp.net now have:
----------------------------------------------------------
Imports System.Web
Imports System.Web.SessionState
Public Class Global
Inherits System.Web.HttpApplication
Function IzDecrypt(ByVal s)
Dim k, x, iKeyChar, iStringChar, iDeCryptChar
k = ReadKeyFromFile()
x = ""
For i = 1 To len(s)
iKeyChar = mid(k, i, 1)
iStringChar = mid(s, i, 1)
iDeCryptChar = expon(iKeyChar, iStringChar)
x = x & iDeCryptChar
Next
IzDecrypt = x
End Function
End Class
-----------------------------------------------------------
but cannot see how I can add the javascript runat server bit so that the asp.net knows about the expon function. (Assume if I change languages this could affect the expon functionality so cannot simply change to asp.net). Can anyone give me suggestions as to whether this is feasible and if so any pointers
Thanks
Andy