473,386 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Can cookie store non-ascii?

Hi - I'm doing simple XOR encryption on a password before storing it in a
cookie. I use the same 2-way encryption/decryption routine at each end
(before writing/after reading). Something is getting screwed up because this
doesn't work as expected. Can cookies store any non-ascii characters? (I'm
thinking that maybe this limitation is what is screwing me up). Thanks,

(I've confirmed that the 2-way encryption using the following routine does
work correctly)

Paul.

-----------
Private Function cryptUserDetails(ByVal strTemp As String) As String
'Encrypts or decrypts a string. This encryption is a simple XOR based on
'a random seed number. Passing the encrypted string will decrypt it, passing
'the unencrypted string will decrypt it. Returns a blank string on error.
'Instring= the string to work with
'KeyValue=the seed value (MUST BE POSITIVE)
Dim X As Integer
Dim KeyValue As Integer
Dim singlechar As String
Dim charnum As Integer
Dim randomint As Integer
Dim OutString As String
Dim i As Integer, Seed As Single

On Error GoTo EncryptError
KeyValue = 133 'Len(strTemp) * 13 'psw addition
OutString = ""
Seed = Rnd(-KeyValue)
For i = 1 To Len(strTemp)
singlechar = Mid$(strTemp, i, 1)
charnum = Asc(singlechar)
randomint = CInt(256 * Rnd())
charnum = charnum Xor randomint
singlechar = Chr(charnum)
OutString = OutString + singlechar
Next i
cryptUserDetails = OutString
Exit Function
EncryptError:
'Encryption error; return a blank string
cryptUserDetails = ""
Exit Function
End Function
Nov 19 '05 #1
1 1804
I would recommend encoding the binary data using something like base64.

"Paul W" <qq*@qqq.com> wrote in message
news:#Y*************@TK2MSFTNGP12.phx.gbl...
Hi - I'm doing simple XOR encryption on a password before storing it in a
cookie. I use the same 2-way encryption/decryption routine at each end
(before writing/after reading). Something is getting screwed up because this doesn't work as expected. Can cookies store any non-ascii characters? (I'm
thinking that maybe this limitation is what is screwing me up). Thanks,

(I've confirmed that the 2-way encryption using the following routine does
work correctly)

Paul.

-----------
Private Function cryptUserDetails(ByVal strTemp As String) As String
'Encrypts or decrypts a string. This encryption is a simple XOR based on
'a random seed number. Passing the encrypted string will decrypt it, passing 'the unencrypted string will decrypt it. Returns a blank string on error.
'Instring= the string to work with
'KeyValue=the seed value (MUST BE POSITIVE)
Dim X As Integer
Dim KeyValue As Integer
Dim singlechar As String
Dim charnum As Integer
Dim randomint As Integer
Dim OutString As String
Dim i As Integer, Seed As Single

On Error GoTo EncryptError
KeyValue = 133 'Len(strTemp) * 13 'psw addition
OutString = ""
Seed = Rnd(-KeyValue)
For i = 1 To Len(strTemp)
singlechar = Mid$(strTemp, i, 1)
charnum = Asc(singlechar)
randomint = CInt(256 * Rnd())
charnum = charnum Xor randomint
singlechar = Chr(charnum)
OutString = OutString + singlechar
Next i
cryptUserDetails = OutString
Exit Function
EncryptError:
'Encryption error; return a blank string
cryptUserDetails = ""
Exit Function
End Function

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ian | last post by:
I have a problem I hope someone can point out where I am going wrong. I need to store a date/time in a cookie ( ie the date a visitor last visited ) However the date format changes to US, despite...
0
by: obhayes | last post by:
Hi All, Im using classic ASP (3.0) and I have a web farm with 2 webservers (webserver A and webserver B, both windows server 2003). I do not want to store any client specific information on the...
1
by: brad | last post by:
Hi, Im using classic ASP (3.0) and I have a web farm with 2 webservers (webserver A and webserver B, both windows server 2003). I do not want to store any client specific information on the...
9
by: Marco Krechting | last post by:
Hi All, I have a page with a list of hyperlinks. I want to save information in a cookie about the fact that I entered an hyperlink or not. When I click one of the hyperlinks I want this stored...
7
by: Doug | last post by:
An ASP.NET session cookie set on "www.mydomain.com" can not be accessed on "search.mydomain.com"; hence, a new session and cookie are being created on every sub-domain. This is occuring because...
15
by: Edwin Knoppert | last post by:
I have searched but info is limitted. In my test app i used a non persistant cookie for forms authentication. slidingExpiration is set to true On run and close and rerun the login remains ok....
1
by: Joe | last post by:
In ASP.NET 1.1 I could detected expired form authentication tickets (which closely coincide with my expired session) by checking for the Authentication Cookie when the login screen loads. If the...
3
by: Mike | last post by:
Hi, Upon login into my application I stored user data (userid, ...) in a cookie to be used throughout the application. One particular form is very complicated that uses AJAX and many AJAX...
4
by: nemesisqp | last post by:
I am writing a php script that login to apple.com , to do that I use a http analyzer to monitor normal login process I see to login I need open 3 connection 1:...
7
by: =?Utf-8?B?SlA=?= | last post by:
I need to design a WS that will after authenicating the user, create a cookie on the users PC that made the request. All the code I keep finding is how to get a WS to read a cookie, I need it to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.