K
Khor Soon Hua
when i run the following code, the above error is occured. can anybody
help me? sorry cosz it is a vb.net code.
Public Function Decrypt(ByVal strToDecrypt As String) As String
Dim sb As New StringBuilder
Dim byteToDecrypt() As Byte = Convert.FromBase64String(strToDecrypt)
Dim byteDecoded(byteToDecrypt.Length) As Byte
Dim ms As New MemoryStream(byteToDecrypt)
Dim cs As CryptoStream
Try
byteKey = GetKey(strKey)
byteIV = GetKey(strIV)
Dim desProvider As New DESCryptoServiceProvider
cs = New CryptoStream(ms, desProvider.CreateDecryptor(byteKey,
byteIV), CryptoStreamMode.Read)
cs.Read(byteDecoded, 0, byteDecoded.Length)
cs.FlushFinalBlock()
Catch ex As Exception
Throw New Exception(ex.Message)
Finally
ms.Close()
cs.Close()
End Try
Dim intLength As Integer = byteDecoded.Length - 1
For i As Integer = 0 To intLength
sb.Append(byteDecoded(i).ToString)
Next
Return sb.ToString
End Function
help me? sorry cosz it is a vb.net code.
Public Function Decrypt(ByVal strToDecrypt As String) As String
Dim sb As New StringBuilder
Dim byteToDecrypt() As Byte = Convert.FromBase64String(strToDecrypt)
Dim byteDecoded(byteToDecrypt.Length) As Byte
Dim ms As New MemoryStream(byteToDecrypt)
Dim cs As CryptoStream
Try
byteKey = GetKey(strKey)
byteIV = GetKey(strIV)
Dim desProvider As New DESCryptoServiceProvider
cs = New CryptoStream(ms, desProvider.CreateDecryptor(byteKey,
byteIV), CryptoStreamMode.Read)
cs.Read(byteDecoded, 0, byteDecoded.Length)
cs.FlushFinalBlock()
Catch ex As Exception
Throw New Exception(ex.Message)
Finally
ms.Close()
cs.Close()
End Try
Dim intLength As Integer = byteDecoded.Length - 1
For i As Integer = 0 To intLength
sb.Append(byteDecoded(i).ToString)
Next
Return sb.ToString
End Function