Click here to Skip to main content
15,923,789 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionPostback causing problem Pin
greendragons11-Aug-09 8:23
greendragons11-Aug-09 8:23 
AnswerRe: Postback causing problem Pin
Hemant_ec4811-Aug-09 12:29
Hemant_ec4811-Aug-09 12:29 
GeneralRe: Postback causing problem Pin
greendragons11-Aug-09 13:05
greendragons11-Aug-09 13:05 
AnswerRe: Postback causing problem Pin
yesu prakash12-Aug-09 0:33
yesu prakash12-Aug-09 0:33 
GeneralRe: Postback causing problem Pin
greendragons12-Aug-09 1:38
greendragons12-Aug-09 1:38 
QuestionCrystal Report Problem Please Help Pin
Andile.M11-Aug-09 7:38
Andile.M11-Aug-09 7:38 
AnswerRe: Crystal Report Problem Please Help Pin
David Mujica11-Aug-09 8:02
David Mujica11-Aug-09 8:02 
QuestionVery Wierd quesrystring encryption problem Pin
gfrenkel111-Aug-09 7:10
gfrenkel111-Aug-09 7:10 
I've got a tet box and a button on my page and am using the following code ro encrypt the URL. The only unusual part is is this line in button click event
Dim strValues As String = TextBox1.Text & TextBox1.Text & TextBox1.Text
This I was forced to do beacuse for some reason it didn't like the four digit id (i.e Invalid length for a Base-64 char array) entered into the textbox so I just repeated it three times an on the other side I just look at the first third of the decrypted querysring.

Public Function Encrypt(ByVal stringToEncrypt As String, _
ByVal SEncryptionKey As String) As String
Dim key() As Byte = {}
Dim IV() As Byte = {&H12, &H34, &H56, &H78, &H90, &HAB, &HCD, &HEF}
Try
key = System.Text.Encoding.UTF8.GetBytes(Left(SEncryptionKey, 8))
Dim des As New DESCryptoServiceProvider()
Dim inputByteArray() As Byte = Encoding.UTF8.GetBytes( _
stringToEncrypt)
Dim ms As New MemoryStream()
Dim cs As New CryptoStream(ms, des.CreateEncryptor(key, IV), _
CryptoStreamMode.Write)
cs.Write(inputByteArray, 0, inputByteArray.Length)
cs.FlushFinalBlock()
Return Convert.ToBase64String(ms.ToArray())
Catch e As Exception
Return e.Message
End Try
End Function

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strValues As String = TextBox1.Text & TextBox1.Text & TextBox1.Text
Dim strURL As String = "PasswordReset.aspx?Key=" & Encrypt(strValues, "!#$a54?3")
Response.Redirect(strURL)
End Sub

My decyption code is:


Public Function Decrypt(ByVal stringToDecrypt As String, _
ByVal sEncryptionKey As String) As String
Dim key() As Byte = {}
Dim IV() As Byte = {&H12, &H34, &H56, &H78, &H90, &HAB, &HCD, &HEF}
Dim inputByteArray(stringToDecrypt.Length) As Byte
Try
key = System.Text.Encoding.UTF8.GetBytes(Left(sEncryptionKey, 8))
Dim des As New DESCryptoServiceProvider()
inputByteArray = Convert.FromBase64String(stringToDecrypt)
Dim ms As New MemoryStream()
Dim cs As New CryptoStream(ms, des.CreateDecryptor(key, IV), _
CryptoStreamMode.Write)
cs.Write(inputByteArray, 0, inputByteArray.Length)
cs.FlushFinalBlock()
Dim encoding As System.Text.Encoding = System.Text.Encoding.UTF8
Return encoding.GetString(ms.ToArray())
Catch e As Exception
Return e.Message
End Try
End Function

Everthing works great EXCEPT when I try to decrypt the number 305930593059 (this is 3059 repeated three times). When executing the line: inputByteArray = Convert.FromBase64String(stringToDecrypt) I error out with "Invalid length for a Base-64 char array". Any other number that I try, even 5 digit ones, work fine.
Is this wierd or what?

Thanks in advance for any help.
AnswerRe: Very Wierd quesrystring encryption problem Pin
Abhijit Jana11-Aug-09 7:25
professionalAbhijit Jana11-Aug-09 7:25 
QuestionStreaming image resources from DLL to an ASP.NET page without IHttpHandler Pin
Petri Lehtonen11-Aug-09 5:01
Petri Lehtonen11-Aug-09 5:01 
Questionmultiple DropDownList refreshing Pin
romeodamian11-Aug-09 2:51
romeodamian11-Aug-09 2:51 
QuestionExpression - Evaluate - Very Urgent Pin
sekannak11-Aug-09 2:38
sekannak11-Aug-09 2:38 
AnswerDon't be rude Pin
Not Active11-Aug-09 2:45
mentorNot Active11-Aug-09 2:45 
AnswerRe: Expression - Evaluate - Very Urgent Pin
Arindam Sinha11-Aug-09 2:58
Arindam Sinha11-Aug-09 2:58 
AnswerRe: Expression - Evaluate - Very Urgent Pin
logiclabz11-Aug-09 3:01
logiclabz11-Aug-09 3:01 
QuestionPopulating a crystal report using Stored procedure Pin
LucBite11-Aug-09 2:35
LucBite11-Aug-09 2:35 
AnswerRe: Populating a crystal report using Stored procedure Pin
Venkatesh Mookkan11-Aug-09 16:11
Venkatesh Mookkan11-Aug-09 16:11 
Questionhow to render grid in divs? Pin
mr_muskurahat11-Aug-09 2:31
mr_muskurahat11-Aug-09 2:31 
AnswerRe: how to render grid in divs? Pin
Mike Ellison11-Aug-09 2:41
Mike Ellison11-Aug-09 2:41 
QuestionHow to generate missing PageName.aspx.designer.cs Pin
Chesnokov Yuriy11-Aug-09 1:44
professionalChesnokov Yuriy11-Aug-09 1:44 
AnswerRe: How to generate missing PageName.aspx.designer.cs [modified] Pin
l.czibolya11-Aug-09 3:11
l.czibolya11-Aug-09 3:11 
AnswerRe: How to generate missing PageName.aspx.designer.cs Pin
Abhijit Jana11-Aug-09 3:24
professionalAbhijit Jana11-Aug-09 3:24 
GeneralRe: How to generate missing PageName.aspx.designer.cs Pin
Chesnokov Yuriy11-Aug-09 3:28
professionalChesnokov Yuriy11-Aug-09 3:28 
QuestionRemember Me Pin
janani1311-Aug-09 1:41
janani1311-Aug-09 1:41 
AnswerRe: Remember Me Pin
Mike Ellison11-Aug-09 2:36
Mike Ellison11-Aug-09 2:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.