Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > General Computer Discussion > Software > Encryption In Asp.net

Reply
Thread Tools

Encryption In Asp.net

 
 
ava_h ava_h is offline
Junior Member
Join Date: Oct 2006
Posts: 2
 
      10-21-2006
please help me!
i want to encrypte my string but when
i decrypte it the exception {"Length of the data to decrypt is invalid."}
occur.
what is the problem?
my code:

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim iv As Byte() = {240, 32, 45, 29, 0, 76, 173, 59}
Dim cryptokey As String = "this is a test"
Dim mystring As String = TextBox1.Text
Dim buffer As Byte() = System.Text.Encoding.ASCII.GetBytes(mystring)
Dim des As TripleDESCryptoServiceProvider = New TripleDESCryptoServiceProvider
Dim md5 As MD5CryptoServiceProvider = New MD5CryptoServiceProvider
des.Key = md5.ComputeHash(System.Text.ASCIIEncoding.ASCII.Ge tBytes(cryptokey))
des.IV = iv
Dim codedbuffer As Byte() = des.CreateEncryptor.TransformFinalBlock(buffer, 0, buffer.Length)
Label1.Text = System.Convert.ToBase64String(codedbuffer, 0, codedbuffer.Length)

End Sub

Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim iv As Byte() = {240, 32, 45, 29, 0, 76, 173, 59}

Dim cryptokey As String = "this is a test"
Dim codedstring As String = Label1.Text
'
Dim buffer As Byte() = System.Text.Encoding.ASCII.GetBytes(codedstring)
Dim des As TripleDESCryptoServiceProvider = New TripleDESCryptoServiceProvider
Dim md5 As MD5CryptoServiceProvider = New MD5CryptoServiceProvider
des.Key = md5.ComputeHash(System.Text.ASCIIEncoding.ASCII.Ge tBytes(cryptokey))
des.IV = iv
Dim codedbuffer As Byte() = des.CreateDecryptor.TransformFinalBlock(buffer, 0, buffer.Length)
Label2.Text = System.Convert.ToBase64String(codedbuffer, 0, codedbuffer.Length)
End Sub
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Which hard drive encryption program has the strongest tested encryption & security? =?iso-8859-1?Q?-=3D|__=28=BAL=BA=29__|=3D-____o=3D=5B:::::::::::::::=BB?= Computer Security 6 02-20-2008 01:35 PM
Where are encryption keys stored? Philip Herlihy Wireless Networking 5 07-12-2004 06:31 PM
Configuring an Enterprise wireless solutions with encryption Harrison Midkiff Wireless Networking 0 07-02-2004 06:23 PM
Wireless AP with WPA encryption Joseph Wireless Networking 2 06-28-2004 11:12 AM
Re: windows xp and wep 64bit encryption 1magic Wireless Networking 0 06-17-2004 12:07 AM



Advertisments