Click here to Skip to main content
12,239,797 members (66,981 online)

Visual Basic

 
GeneralRe: Finding a Row in a Datatable and putting the row to variables Pin
JRHibner27-Nov-12 20:28
memberJRHibner27-Nov-12 20:28 
AnswerRe: Finding a Row in a Datatable and putting the row to variables Pin
Andy_L_J27-Nov-12 21:56
memberAndy_L_J27-Nov-12 21:56 
GeneralRe: Finding a Row in a Datatable and putting the row to variables Pin
JRHibner28-Nov-12 0:40
memberJRHibner28-Nov-12 0:40 
GeneralRe: Finding a Row in a Datatable and putting the row to variables Pin
Andy_L_J28-Nov-12 1:20
memberAndy_L_J28-Nov-12 1:20 
GeneralRe: Finding a Row in a Datatable and putting the row to variables Pin
JRHibner28-Nov-12 11:35
memberJRHibner28-Nov-12 11:35 
QuestionChanging Assembly Properties through Reflection Pin
DisIsHoody14-Nov-12 10:38
memberDisIsHoody14-Nov-12 10:38 
AnswerRe: Changing Assembly Properties through Reflection Pin
Eddy Vluggen15-Nov-12 2:18
memberEddy Vluggen15-Nov-12 2:18 
GeneralRe: Changing Assembly Properties through Reflection Pin
DisIsHoody15-Nov-12 18:14
memberDisIsHoody15-Nov-12 18:14 
GeneralRe: Changing Assembly Properties through Reflection Pin
Eddy Vluggen16-Nov-12 1:06
memberEddy Vluggen16-Nov-12 1:06 
Questionmessagebeep Pin
Gil Goodridge14-Nov-12 9:00
memberGil Goodridge14-Nov-12 9:00 
AnswerRe: messagebeep Pin
Dave Kreskowiak14-Nov-12 9:31
mvpDave Kreskowiak14-Nov-12 9:31 
QuestionRijndael encryption not working Pin
maskrtnik0114-Nov-12 3:20
membermaskrtnik0114-Nov-12 3:20 
AnswerRe: Rijndael encryption not working Pin
Keith Barrow14-Nov-12 3:52
mentorKeith Barrow14-Nov-12 3:52 
GeneralRe: Rijndael encryption not working Pin
maskrtnik0114-Nov-12 4:08
membermaskrtnik0114-Nov-12 4:08 
It does not throw any exception.

ExportData method only creates XML document with data to be encrypted. I have checked, that result of ExportData
contains, what it should cotain.

I have also tried following, again, empty file is generated.
Public Sub Save(ByVal carrier As DataCarrier, ByVal password As String, ByVal filename As String)
            Try
                Using sha As New SHA512Managed
                    Dim salt As Byte() = sha.ComputeHash(Encoding.Default.GetBytes(password))
                    Using pdb As New Rfc2898DeriveBytes(password, salt), aes As New RijndaelManaged, filestr As New FileStream(filename, FileMode.Create, FileAccess.Write)
                        Using cryptostr As New CryptoStream(filestr, aes.CreateEncryptor(pdb.GetBytes(32), pdb.GetBytes(16)), CryptoStreamMode.Write)
                            Dim str = ExportData(carrier).ToString()
                            Using w As New StreamWriter(cryptostr)
                                w.Write(str)
                            End Using
                        End Using
                    End Using
                End Using
            Catch ex As Exception
                Logging.Instance.WriteException(ex, TraceEventType.Error)
                MessageBox.Show(String.Format(My.Resources.UnhandledExceptionExString, ex.Message, ex.ToString), My.Application.Info.Title, MessageBoxButtons.OK, MessageBoxIcon.Error)
            End Try
        End Sub

Moreover, I have tried simply writing string literal to CryptoStream, this approach generates empty file too.

Strange is, that when I run this version:
Public Sub Save(ByVal carrier As DataCarrier, ByVal password As String, ByVal filename As String)
           Try
               Using sha As New SHA512Managed
                   Dim salt As Byte() = sha.ComputeHash(Encoding.Default.GetBytes(password))
                   Using pdb As New Rfc2898DeriveBytes(password, salt), aes As New RijndaelManaged, filestr As New MemoryStream() 'filestr As New FileStream(filename, FileMode.Create, FileAccess.Write)
                       Using cryptostr As New CryptoStream(filestr, aes.CreateEncryptor(pdb.GetBytes(32), pdb.GetBytes(16)), CryptoStreamMode.Write)
                           ExportData(carrier).Save(cryptostr)
                           Dim str = New String(Encoding.Default.GetChars(filestr.ToArray()))
                           Debugger.Break()
                       End Using
                   End Using
               End Using
           Catch ex As Exception
               Logging.Instance.WriteException(ex, TraceEventType.Error)
               MessageBox.Show(String.Format(My.Resources.UnhandledExceptionExString, ex.Message, ex.ToString), My.Application.Info.Title, MessageBoxButtons.OK, MessageBoxIcon.Error)
           End Try
       End Sub
Then at Debugger.Break statement str variable cotains data, which should be in the file.

While this and simmilar solutions generate empty file.
Public Sub Save(ByVal carrier As DataCarrier, ByVal password As String, ByVal filename As String)
            Try
                Using sha As New SHA512Managed
                    Dim salt As Byte() = sha.ComputeHash(Encoding.Default.GetBytes(password))
                    Using pdb As New Rfc2898DeriveBytes(password, salt), aes As New RijndaelManaged, filestr As New MemoryStream() 'filestr As New FileStream(filename, FileMode.Create, FileAccess.Write)
                        Using cryptostr As New CryptoStream(filestr, aes.CreateEncryptor(pdb.GetBytes(32), pdb.GetBytes(16)), CryptoStreamMode.Write)
                            ExportData(carrier).Save(cryptostr)
                            File.WriteAllBytes(filename, filestr.ToArray())
                            Debugger.Break()
                        End Using
                    End Using
                End Using
            Catch ex As Exception
                Logging.Instance.WriteException(ex, TraceEventType.Error)
                MessageBox.Show(String.Format(My.Resources.UnhandledExceptionExString, ex.Message, ex.ToString), My.Application.Info.Title, MessageBoxButtons.OK, MessageBoxIcon.Error)
            End Try
        End Sub

I am really confused on what it does.
GeneralRe: Rijndael encryption not working Pin
Keith Barrow14-Nov-12 4:26
mentorKeith Barrow14-Nov-12 4:26 
GeneralRe: Rijndael encryption not working Pin
Keith Barrow14-Nov-12 4:35
mentorKeith Barrow14-Nov-12 4:35 
GeneralRe: Rijndael encryption not working Pin
maskrtnik0114-Nov-12 4:48
membermaskrtnik0114-Nov-12 4:48 
GeneralRe: Rijndael encryption not working Pin
Keith Barrow14-Nov-12 5:05
mentorKeith Barrow14-Nov-12 5:05 
QuestionRe: Rijndael encryption not working Pin
maskrtnik0115-Nov-12 20:40
membermaskrtnik0115-Nov-12 20:40 
GeneralRe: Rijndael encryption not working Pin
DisIsHoody14-Nov-12 10:34
memberDisIsHoody14-Nov-12 10:34 
GeneralRe: Rijndael encryption not working Pin
maskrtnik0114-Nov-12 19:21
membermaskrtnik0114-Nov-12 19:21 
AnswerRe: Rijndael encryption not working Pin
DisIsHoody15-Nov-12 18:37
memberDisIsHoody15-Nov-12 18:37 
GeneralRe: Rijndael encryption not working Pin
maskrtnik0115-Nov-12 20:37
membermaskrtnik0115-Nov-12 20:37 
QuestionRetrive date from sql server in system date format in VB6 application by a one time setting Pin
Johnson Antony13-Nov-12 14:34
memberJohnson Antony13-Nov-12 14:34 
AnswerRe: Retrive date from sql server in system date format in VB6 application by a one time setting Pin
Dave Kreskowiak13-Nov-12 15:00
mvpDave Kreskowiak13-Nov-12 15:00 
QuestionHow to find out if a file is in use before reading the data in that file Pin
KreativeKai13-Nov-12 8:47
memberKreativeKai13-Nov-12 8:47 
AnswerRe: How to find out if a file is in use before reading the data in that file Pin
Dave Kreskowiak13-Nov-12 9:09
mvpDave Kreskowiak13-Nov-12 9:09 
GeneralRe: How to find out if a file is in use before reading the data in that file Pin
KreativeKai13-Nov-12 9:22
memberKreativeKai13-Nov-12 9:22 
GeneralRe: How to find out if a file is in use before reading the data in that file Pin
KreativeKai13-Nov-12 9:46
memberKreativeKai13-Nov-12 9:46 
AnswerRe: How to find out if a file is in use before reading the data in that file Pin
KreativeKai13-Nov-12 9:13
memberKreativeKai13-Nov-12 9:13 
GeneralRe: How to find out if a file is in use before reading the data in that file Pin
Dave Kreskowiak13-Nov-12 10:57
mvpDave Kreskowiak13-Nov-12 10:57 
AnswerRe: How to find out if a file is in use before reading the data in that file Pin
Eddy Vluggen13-Nov-12 12:41
memberEddy Vluggen13-Nov-12 12:41 
GeneralRe: How to find out if a file is in use before reading the data in that file Pin
KreativeKai14-Nov-12 2:37
memberKreativeKai14-Nov-12 2:37 
GeneralRe: How to find out if a file is in use before reading the data in that file Pin
VitorHugoGarcia19-Nov-12 2:12
memberVitorHugoGarcia19-Nov-12 2:12 
QuestionVB Script for automatically turning off the monitor Pin
Prasan Cumar13-Nov-12 5:14
memberPrasan Cumar13-Nov-12 5:14 
AnswerRe: VB Script for automatically turning off the monitor Pin
Dave Kreskowiak13-Nov-12 5:59
mvpDave Kreskowiak13-Nov-12 5:59 
AnswerRe: VB Script for automatically turning off the monitor Pin
Bernhard Hiller13-Nov-12 22:20
memberBernhard Hiller13-Nov-12 22:20 
QuestionSQL Configuration Pin
DinoRondelly13-Nov-12 4:46
memberDinoRondelly13-Nov-12 4:46 
AnswerRe: SQL Configuration Pin
David Mujica13-Nov-12 5:07
memberDavid Mujica13-Nov-12 5:07 
GeneralRe: SQL Configuration Pin
DinoRondelly13-Nov-12 6:56
memberDinoRondelly13-Nov-12 6:56 
GeneralRe: SQL Configuration Pin
David Mujica13-Nov-12 10:44
memberDavid Mujica13-Nov-12 10:44 
GeneralRe: SQL Configuration Pin
DinoRondelly13-Nov-12 19:17
memberDinoRondelly13-Nov-12 19:17 
QuestionSource Code Pin
Member 939009712-Nov-12 16:59
memberMember 939009712-Nov-12 16:59 
AnswerRe: Source Code Pin
Dave Kreskowiak13-Nov-12 3:20
mvpDave Kreskowiak13-Nov-12 3:20 
QuestionMonitoring Network Usage For Remote Users Pin
DinoRondelly12-Nov-12 11:54
memberDinoRondelly12-Nov-12 11:54 
AnswerRe: Monitoring Network Usage For Remote Users Pin
Eddy Vluggen13-Nov-12 12:44
memberEddy Vluggen13-Nov-12 12:44 
QuestionScan Multipage Tiff Image For A Barcode Pin
daveofgv12-Nov-12 5:07
memberdaveofgv12-Nov-12 5:07 
AnswerRe: Scan Multipage Tiff Image For A Barcode Pin
Eddy Vluggen12-Nov-12 11:54
memberEddy Vluggen12-Nov-12 11:54 
QuestionGetting All Logged On Users and IP VB.net Pin
DinoRondelly12-Nov-12 4:39
memberDinoRondelly12-Nov-12 4:39 
AnswerRe: Getting All Logged On Users and IP VB.net Pin
Dave Kreskowiak12-Nov-12 5:37
mvpDave Kreskowiak12-Nov-12 5:37 

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.


Advertise | Privacy | Mobile
Web02 | 2.8.160426.1 | Last Updated 26 Apr 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid