Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi...Does anyone know any two-way encryption algoritm. I have been trying to use the DES and the TripleDES algorithms but the problem with these is I am not able to pass the encrypted string through the querystring as the encrypted string has some special characters in it. Any ideas?

 

For instance when I am trying to encrypt the number "126" using DES encryption method, the encrypted string is 'lng0+5+6Utk=' which cannot be passed through the querystring because of the '+' character. I dont know why!!

 

SJ

Posted

Hi...It is not working. For some reason, the character '+' in the encoded string is vanishing even when HttpUtility.HtmlDecode() is used on the encrypted string. Is there any significance for the '+' char in the querystring?

 

SJ

Posted
Maybe HtmlUrlEncode ?

"If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown

"Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me

"A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend.

C# TO VB TRANSLATOR

Posted

HttpUtility.UrlPathEncode(...) then ?

 

If it work... alright...everythings perfect

If it doesn't... try bashing your case with a hammer. I heard that it solve most of the problem "into" your computer. :D

 

If none of above work... you'll have to convert char from "+" to %343 (not the right value) you know ? Their ANSI value in integer. (Isn't it ?)

"If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown

"Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me

"A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend.

C# TO VB TRANSLATOR

Posted

Hi..That is not working either. All the encoding and decoding is making the '+' character vanish!!! And I am having this problem for the '+' char alone. I have'nt come across anything else yet. So, I cannot write any code to replace the '+' char with whatever ascii value it has.

 

Do you know any two-way encryption algorithm that does not give any special characters in the encoded string. For ex: the MD5 and SHA1 encryption algorithms returns the encrypted strings in alphabets and numbers only. But both of them are one-way encryption algorithms!!

 

SJ

Posted

Encoding

 

Wasn't damn able to find a suitable function so I build ya one

 

[/color][/size][size=2][color=#0000ff]public[/color][/size][size=2][color=#0000ff]string[/color][/size][size=2] Encode([/size][size=2][color=#0000ff]string[/color][/size][size=2] str)[/size]
[size=2]{[/size]
[size=2][color=#0000ff]   string[/color][/size][size=2] ret = "";[/size]
[size=2]   System.Text.Encoding ascii = System.Text.Encoding.ASCII;[/size]
[size=2][color=#0000ff]   byte[/color][/size][size=2][] bs = ascii.GetBytes(str);[/size]
[size=2][color=#0000ff]   foreach[/color][/size][size=2]( [/size][size=2][color=#0000ff]byte[/color][/size][size=2] b [/size][size=2][color=#0000ff]in[/color][/size][size=2] bs)[/size]
[size=2]   {[/size]
[size=2]     ret += "&" + b + ";";[/size]
[size=2]   }[/size]
[size=2][color=#0000ff]   return[/color][/size][size=2] ret;[/size]
[size=2]}[/size][size=2]

 

That's it... they are now encoded... find a way now to deencode them :D

Other people want me you see what I mean :cool:

"If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown

"Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me

"A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend.

C# TO VB TRANSLATOR

Posted

Hi...Thanks for the code. Infact, my code is working with a small change that I have made. Instead of using Server.URLEncode, I used HTTPUtility.URLEncode when passing the encrypted string into the URL like this:

 

"./sample.aspx?id=" & HttpUtility.UrlEncode(CryptoUtil.EncryptTripleDES(dr.Item("idnum")))

 

But when I am trying to read from the querystring, I am not using any HTTPUtility.URLDecode. Like this:

 

CInt(CryptoUtil.Decrypt(Request.QueryString("id")))

 

Everything is working great.

 

Thanks

SJ

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...