Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

QS encryption - how to de-encrypt - 5.30am urgent - please help!

Status
Not open for further replies.

leeolive

Programmer
May 14, 2002
46
0
0
GB
Hi!

I am trying to work out your encryption and I think my brain has passed it's expiry date. I can't figure out the logistics of this - I am new to asp and functions.

I think that I have managed to encrypt the QS on the response.redirect of my 'submit.asp page'. This value now gets passed by response.redirect to 'process.asp' with a link to another page called 'printinstructions.asp'.

This value now retrieved on 'process.asp' page now needs to be passed when the link is clicked. Where and how do I perform the de-encrypt? When the link is clicked before going to the page, or on body load of 'printinstructions.asp'? How do I do this?

Thanks, appreciate it!
Lee

Here is the function that's on the submit.asp

'encrypt
Function Encrypt(ByVal TheString)
Dim x, i, tmp
For i = 1 To Len( TheString )
x = Mid( Thestring, i, 1 )
tmp = tmp & Chr( Asc( x ) + 1 )
Next
tmp = StrReverse( tmp )
Encrypt = tmp
End Function

Function Decrypt(ByVal encryptedstring)
Dim x, i, tmp, final
encryptedstring = StrReverse( encryptedstring )
For i = 1 To Len( encryptedstring )
x = Mid( encryptedstring, i, 1 )
tmp = tmp & Chr( Asc( x ) - 1 )
Next
Decrypt = tmp
End Function
'end encrypt

**Here's the response.redirect, also on submit.asp**

if err.number = 0 then
Response.redirect "process.asp?id=" & Encrypt (strNINumber) 'added
Response.End

This passes id to process.asp where there is a link which should post/qs the value to printinstructions.asp. When are how do I do it and what is the syntax?

 
Hi, I've tweaked the functions a little bit. You should have a bit more joy now:

Here's some revised code showing a value being encrypted and decrypted:

'*** start of code ***

'encrypt function code
Function Encrypt(TheString)
Dim x, i, tmp
For i = 1 To Len( TheString )
x = Mid( Thestring, i, 1 )
tmp = tmp & Chr( Asc( x ) + 1 )
Next
TheString = StrReverse( tmp )
End Function
'end of encrypt function code

'start of decrypt function code
Function Decrypt(encryptedstring)
Dim x, i, tmp
encryptedstring = StrReverse( encryptedstring )
For i = 1 To Len( encryptedstring )
x = Mid( encryptedstring, i, 1 )
tmp = tmp & Chr( Asc( x ) - 1 )
Next
encryptedstring = tmp
End Function
'end of decrypt function code

'set the value for the string you want to process
Dim AString
theStringToBeProcessed = "tea and scones"

' pass theStringToBeProcessed variable to the Encrypt function
Call Encrypt ( theStringToBeProcessed )

' check theStringToBeProcessed variable value has changed
Response.Write "This is the string encrypted: " & theStringToBeProcessed

' pass theStringToBeProcessed variable to the DeEncrypt function
Call Decrypt ( theStringToBeProcessed )

' check theStringToBeProcessed variable value has changed back
Response.Write "<br> This is the string decrypted again: " & theStringToBeProcessed

'*** end of code

If you're using this on a form submit page you'll need something like this:

IF Request.Form("NINumber") <> "" THEN
NINumber = Request.Form("NINumber")
CALL encrypt ( NINumber )
Response.Redirect ("theNextPage.asp?NINumber=" & NINumber)
END IF

You'll also need to include the encrypt function on this page.

On the receiving page you'll need to include the decrypt function. To get the querystring NINumber back de-crypted you'll need something like.

IF Request.Querystring("NINumber") <> "" THEN
NINumber = Request.Querystring("NINumber")
CALL decrypt ( NINumber )
Response.Write NINumber
END IF

Hope this helps.

I've just realised this question was posted ages ago but now this is written I'm not going to delete it all!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top