Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cannot get Try Catch to handle error
Message
From
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:
01308584
Views:
8
>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.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform