Click here to Skip to main content
15,899,314 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
QuestionRe: Best practice for updating UI in multi-threaded app Pin
bobishkindaguy8-Jul-09 12:51
bobishkindaguy8-Jul-09 12:51 
AnswerRe: Best practice for updating UI in multi-threaded app Pin
supercat98-Jul-09 13:01
supercat98-Jul-09 13:01 
QuestionHow to get http request?? Pin
david bagaturia5-Jul-09 9:21
david bagaturia5-Jul-09 9:21 
AnswerRe: How to get http request?? Pin
Mark Salsbery6-Jul-09 10:05
Mark Salsbery6-Jul-09 10:05 
GeneralRe: How to get http request?? Pin
david bagaturia6-Jul-09 10:35
david bagaturia6-Jul-09 10:35 
GeneralRe: How to get http request?? Pin
0x3c06-Jul-09 10:41
0x3c06-Jul-09 10:41 
QuestionTroy's looking Pin
Troy Russell5-Jul-09 6:28
Troy Russell5-Jul-09 6:28 
QuestionHelp needed in decryption with TripleDes method Pin
ChiSmile5-Jul-09 2:47
ChiSmile5-Jul-09 2:47 
hello all,
am using TripleDes as the encryption method in the code below. The encryption went on successfully but i dont seem to know what is happening when I want to decrypt the data, the "null reference error" keeps on popping up.
What am i not getting right in the code?
Pls, I will appreciate any help.
Thank a lot.







    Private Sub decryptBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles decryptBtn.Click

        Try

            Dim deRecData As String
            ' Dim decTripDe As New TripleDES
            Dim decData As New TripleDES


            LoadData()
            ' Configure and execute the command.
            cmd = New System.Data.SqlClient.SqlCommand("SELECT * FROM Lab where patient_Id = @Pat_ID")
            cmd.Connection = cn
            Dim paraPatId As SqlParameter = cmd.Parameters.Add("@Pat_ID", txtEncryptedBytes.Text)
            ' Load the DataTable.
            datadapt = New System.Data.SqlClient.SqlDataAdapter(cmd)
            ds = New DataSet
            datadapt.Fill(ds)
            ds.Tables.Add(dt)
            'datGrid.DataSource = ds.Tables(0)
            cn.Close()

            'Dim dt As DataTable
            'Dim dc As DataColumn
            Dim dRow As DataRow
            dRow = dt.NewRow
            For Each dRow In ds.Tables("Lab").Rows
                decData = New TripleDES()
                deRecData = decData.Decrypt(dt.Rows(0)("Test_type"))' -->error here, null reference
                dt.Rows.Add(deRecData)
                ds.Tables.Add(dt)
                MsgBox("what is that")
            Next
            datGrid.DataSource = ds.Tables(0)

        Catch ex As SqlException
            MsgBox(ex.Message.ToString())
        Finally

        End Try
    End Sub







Public Function Decrypt(ByVal inputInBytes() As Byte) As String
        ' UTFEncoding is used to transform the decrypted Byte Array
        ' information back into a string.
        Dim utf8encoder As UTF8Encoding = New UTF8Encoding()
        Dim tdesProvider As TripleDESCryptoServiceProvider = New TripleDESCryptoServiceProvider()

        ' As before we must provide the encryption/decryption key along with
        ' the init vector.
        Dim cryptoTransform As ICryptoTransform = tdesProvider.CreateDecryptor(Me.key, Me.iv)

        ' Provide a memory stream to decrypt information into
        Dim decryptedStream As MemoryStream = New MemoryStream()
        Dim cryptStream As CryptoStream = New CryptoStream(decryptedStream, cryptoTransform, CryptoStreamMode.Write)
        cryptStream.Write(inputInBytes, 0, inputInBytes.Length)
        cryptStream.FlushFinalBlock()
        decryptedStream.Position = 0

        ' Read the memory stream and convert it back into a string
        Dim result(decryptedStream.Length - 1) As Byte
        decryptedStream.Read(result, 0, decryptedStream.Length)
        cryptStream.Close()
        Dim myutf As UTF8Encoding = New UTF8Encoding()
        Return myutf.GetString(result, 0, decryptedStream.Length)
    End Function
End Class       

AnswerRe: Help needed in decryption with TripleDes method Pin
Alan N5-Jul-09 3:24
Alan N5-Jul-09 3:24 
GeneralRe: Help needed in decryption with TripleDes method Pin
ChiSmile5-Jul-09 4:58
ChiSmile5-Jul-09 4:58 
GeneralRe: Help needed in decryption with TripleDes method Pin
Henry Minute5-Jul-09 5:53
Henry Minute5-Jul-09 5:53 
GeneralRe: Help needed in decryption with TripleDes method Pin
ChiSmile5-Jul-09 15:08
ChiSmile5-Jul-09 15:08 
QuestionHow to Display ads on .Net form? Pin
slimtugo4-Jul-09 23:50
slimtugo4-Jul-09 23:50 
AnswerRe: How to Display ads on .Net form? Pin
Eddy Vluggen4-Jul-09 23:58
professionalEddy Vluggen4-Jul-09 23:58 
QuestionRe: How to Display ads on .Net form? Pin
slimtugo7-Jul-09 8:01
slimtugo7-Jul-09 8:01 
AnswerRe: How to Display ads on .Net form? Pin
Eddy Vluggen7-Jul-09 8:29
professionalEddy Vluggen7-Jul-09 8:29 
GeneralRe: How to Display ads on .Net form? Pin
slimtugo12-Jul-09 20:42
slimtugo12-Jul-09 20:42 
QuestionOpen Password protected file Pin
ksss_maheshece3-Jul-09 23:58
ksss_maheshece3-Jul-09 23:58 
AnswerRe: Open Password protected file Pin
Colin Angus Mackay4-Jul-09 0:07
Colin Angus Mackay4-Jul-09 0:07 
GeneralRe: Open Password protected file Pin
ksss_maheshece4-Jul-09 0:36
ksss_maheshece4-Jul-09 0:36 
GeneralRe: Open Password protected file Pin
Colin Angus Mackay4-Jul-09 1:03
Colin Angus Mackay4-Jul-09 1:03 
GeneralRe: Open Password protected file Pin
MaheshSelva4-Jul-09 6:30
MaheshSelva4-Jul-09 6:30 
GeneralRe: Open Password protected file [modified] Pin
harold aptroot4-Jul-09 6:45
harold aptroot4-Jul-09 6:45 
GeneralRe: Open Password protected file Pin
Colin Angus Mackay4-Jul-09 6:51
Colin Angus Mackay4-Jul-09 6:51 
Question3D project for VB.Net Pin
phowarso3-Jul-09 20:28
phowarso3-Jul-09 20:28 

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.