Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Understanding codepages and encoding
Message
From
24/10/2006 13:52:21
Alexandre Palma
Harms Software, Inc.
Alverca, Portugal
 
 
To
24/10/2006 13:40:51
Bill Oeftering
Mainstreet Computers, Inc.
Belleville, Michigan, United States
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Miscellaneous
Thread ID:
01164137
Message ID:
01164142
Views:
14
>Newbee to .NET
>I have a simple encrption function that modifies the ascii values in a string. The result contains ascii values from 32 - 255. I'm having a problem with some bytes over 127. I think my string is being converted to unicode. Specificaly values of 131 are converted to 63. How do I create a function that returns a string without converting it ? Thanks, code is below:
> public String gaEncrypt(string tcText,string tcPass)
> {
> string lctext="";
> int lntext=0;
> int lnchar = 0;
> int lnpass = 0;
> for (lntext = 0; lntext < tcText.Length;lntext++)
> {
> lnchar = (int)tcText[lntext] + (int)tcPass[lnpass];
> if ((lnchar > 0) && (lnchar < 256))
> lctext=lctext+(char)lnchar;
> lnpass++;
> if (lnpass > tcPass.Length-1)
> lnpass = 0;
> }
>
> return lctext;
> }
you should return in in Base 64 string, try this
Return system.Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(lctext))
then on ur decrypt function you should do the oposite.
Also did you take a look to the .net System.Security.Cryptography Namespace?
Alexandre Palma
Senior Application Architect
Previous
Reply
Map
View

Click here to load this message in the networking platform