473,466 Members | 1,370 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

TripleDESCryptoServiceProvider

Hi,

I am using TripleDESCryptoServiceProvider to encrypt a value in the
querystring and my only concern is whether will the ampersand character
appear in an encrypted string.

Using POST is not an option so I really need help on this.

Thanks In Advance,
Alex
Jul 5 '06 #1
6 3295
Alex wrote:
I am using TripleDESCryptoServiceProvider to encrypt a value in the
querystring and my only concern is whether will the ampersand character
appear in an encrypted string.

Using POST is not an option so I really need help on this.
Encryption doesn't create strings, it creates binary data. How you
encode that binary data is up to you. If you use base16 (i.e. hex) you
certainly won't get any ampersands. If you use base64, you could use a
non-standard set of characters which are websafe, although I seem to
remember it's only *just* possible. How large is the encrypted value?
If it's small, using hex is probably the simplest solution.

Jon

Jul 5 '06 #2
Hi Jon,

I guess I am using Base64 encoding (ToBase64String and FromBase64String).
How do I use Base16?

The data to encrypt is email address so it should be small.

Thanks,
Yong Teck

"Jon Skeet [C# MVP]" wrote:
Alex wrote:
I am using TripleDESCryptoServiceProvider to encrypt a value in the
querystring and my only concern is whether will the ampersand character
appear in an encrypted string.

Using POST is not an option so I really need help on this.

Encryption doesn't create strings, it creates binary data. How you
encode that binary data is up to you. If you use base16 (i.e. hex) you
certainly won't get any ampersands. If you use base64, you could use a
non-standard set of characters which are websafe, although I seem to
remember it's only *just* possible. How large is the encrypted value?
If it's small, using hex is probably the simplest solution.

Jon

Jul 5 '06 #3
Hi Jon,

I guess I am using Base64 (ToBase64String and FromBase64String). How do I
use Base16? The data to encrypt is email address so it should be small.

Thanks,
Alex

"Jon Skeet [C# MVP]" wrote:
Alex wrote:
I am using TripleDESCryptoServiceProvider to encrypt a value in the
querystring and my only concern is whether will the ampersand character
appear in an encrypted string.

Using POST is not an option so I really need help on this.

Encryption doesn't create strings, it creates binary data. How you
encode that binary data is up to you. If you use base16 (i.e. hex) you
certainly won't get any ampersands. If you use base64, you could use a
non-standard set of characters which are websafe, although I seem to
remember it's only *just* possible. How large is the encrypted value?
If it's small, using hex is probably the simplest solution.

Jon

Jul 5 '06 #4
Alex wrote:
I guess I am using Base64 (ToBase64String and FromBase64String). How do I
use Base16? The data to encrypt is email address so it should be small.
Here's some code I wrote a while ago to convert *from* a hex string.
Converting *to* a hex string is just a case of using a StringBuilder
and appending each byte with the appropriate format (which I forget
off-hand, but it's probably x2 or something like that).

static int ParseHexDigit(char c)
{
if (c >= '0' && c <= '9')
{
return c-'0';
}
if (c >= 'a' && c <= 'f')
{
return c-'a'+10;
}
if (c >= 'A' && c <= 'F')
{
return c-'A'+10;
}
throw new ArgumentException ("Invalid hex character");
}

public static string ParseHex(string hex)
{
char[] result = new char[hex.Length/2];
int hexIndex=0;
for (int i=0; i < result.Length; i++)
{
result[i] = (char)(ParseHexDigit(hex[hexIndex++])*16+
ParseHexDigit(hex[hexIndex++]));

}
return new string (result);
}

Jon

Jul 5 '06 #5
Thanks for Jon's informative inputs.

Hi Alex,

Since your concern here is to avoid those URL sensitive chars in your
querystring value(encrypted through 3DES CSP), I think you can also
consider performing UrlEncoding on the encrypted querystring value(even if
you're using BASE64 convertion). And the HttpUtility.UrlEncode method just
help perform url encoding on a give string(which will replace any chars
which are not allowed in url with escaped values)

#HttpUtility.UrlEncode Method (String)
http://msdn2.microsoft.com/en-us/library/4fkewx0t.aspx

Hope this also helps some.

Regards,

Steven Cheng
Microsoft MSDN Online Support Lead
==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Jul 5 '06 #6
Hello Alex,

How are you doing on this issue? Have you got any further progress or does
my last reply also helps a little? If you still have any problems or there
is anything else we can help ,please don't hesitate to post here.

Regards,

Steven Cheng
Microsoft MSDN Online Support Lead
==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Jul 7 '06 #7

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

Similar topics

7
by: Niyazi | last post by:
Hi, I developed an application and I am using SQL Server 2000 developer edition. I create my database and I have also created tbl_USER table. I have an ID, RealName, UserName, and UserPassword...
7
by: c duden | last post by:
I am attempting to encrypt some text and be able to decrypt it at a later time. I have two methods to do this: public static Byte EncryptText(string textToEncrypt, string encryptionHash) {...
8
by: wkodie | last post by:
I'm having trouble encrypting/decrypting a simple string using the System.Security.Cryptography.TripleDESCryptoServiceProvider, etc... The encryption works, but the decryption does not properly...
4
by: JC | last post by:
Hi all, I have seem few messages posted regaring this but as yet have been able to get this code to work. The plan was to encrypt some string then pass the result to another function that woudl...
3
by: Todd Gruben | last post by:
I am trying to send some encrypted data from a php application to be decoded in a .Net application. Both apps encode/decode a given string but generate different encrypted results. Anyone have...
3
by: v.Seydewitz | last post by:
Hello NG, How can I decrypt an des ede3 encrypted string with .NET? The string was encrypted by using the OpenSSL Method des-ede3-cbc. Thank You! Joachim
3
by: Chris Fink | last post by:
Should the web.config file be included in my deployment, IE physically located in the web app's virtual directory on a release? It makes me nervous having my DB conn string, etc in a ASCII file so...
5
by: jdn | last post by:
I'm new to using this part of the framework, so I'm hoping I've done something obviously stupid, which someone will be able to point out in an obvious manner. Most of the samples I've seen...
1
by: Sathyaish | last post by:
I have the following scenario: Algorithm: 3DES Cipher Mode: CBC Key Size: 128-bit Block Size: 64 bit IV: 0x0000000000000000 (an eight byte array of zeros) The results I get using .NET with...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.