Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cannot get Try Catch to handle error
Message
From
07/04/2008 14:21:47
 
 
To
06/04/2008 16:43:58
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01307868
Message ID:
01308803
Views:
9
>>But it's not clear where and how you are seeing this message? IAC, it would seem that this particular .FromBase64String() is not causing the problem.
>>FWIW there are two exception messages for .FromBase64String() - the one you see and "Invalid character in a Base-64 string". The latter takes precedence so you can be confident that there are no invalid characters in the string.
>>See help for valid length - basically the number of non-whitespace characters must be zero or a multiple of four.
>>If you are creating initVector somewhere how are you doing it?
>
>Here is the Decrypt() method:
>
>
>        Public Function Decrypt(ByVal data As String, ByVal userKey As String, _
>         ByVal alg As EncryptionAlgorithm) As Boolean
>            Dim tok As [String]() = data.Split(New Char() {" "c})
>            Dim initVector As [String] = tok(0)
>
>            data = tok(1)
>
>            ' Set up the Decryptor object
>            Dim dec As New Decryptor(alg)
>
>            ' Set the Initialization Vector
>            dec.IV = Convert.FromBase64String(initVector)
>
>            Dim key As Byte() = Encoding.Default.GetBytes(userKey)
>
>            ' Perform the decryption
>            If Not dec.Decrypt(Convert.FromBase64String(data), key) Then
>               Return False
>            End If
>
>            cDecrypt = Encoding.Default.GetString(dec.oByte)
>            Return True
>        End Function
>
>
>I adjusted it to remove the Try Catch so it would be easier to follow it.

Like Bonnie I'm now confused. The above doesn't tell me anything about the content of InitVector. But I think we're all agreed that the dec.IV assign line (which you originally had in the try block?) could not have been the cause of the message you were seeing. But you didn't explain where this message was originating from. IAC could the error have been in the second use of Convert.FromBase64String ?
Regards,
Viv
Previous
Reply
Map
View

Click here to load this message in the networking platform