Database Extraction Help
-
Am I extracting the blob file correctly?
Private Function decryption()
'This is function is the same as encryption with just a few changes' 'loading the xml document' Dim key As Byte() Dim IV As Byte() 'The hardcoded password goes here' 'This is a section just in case you want to a password to your encrypted files' key = keyencryption(LoginForm.Password\_TextBox.Text) IV = IVCreation(LoginForm.Password\_TextBox.Text) 'if there is an error in the application. A error message will be displayed' Try 'checking to make sure the text box isn't null' If (Decrypt\_TextBox.Text = "") Then MessageBox.Show("Need to put in the file location or select file in grid for decryption") Else 'declaring string for file' Dim filename As String 'Getting the file name that is selected' filename = getFilename() 'Starting to abstract the data from the database' database.ConnectionString = "Data Source = FileVault.db3;" database.Open() Dim command As SQLite.SQLiteCommand Dim sqlstatement As String command = database.CreateCommand 'The following will get the bytes of the file' Dim filesize As Integer sqlstatement = "SELECT FileSize From Vault WHERE FileName=@file;" command.CommandText = sqlstatement command.Parameters.AddWithValue("@file", filename) Dim reader As SQLite.SQLiteDataReader reader = command.ExecuteReader filesize = reader.GetValue(0) reader.Close() MessageBox.Show(filesize) Dim data(filesize) As Byte 'The following should get the data' sqlstatement = "SELECT FileData FROM Vault WHERE FileName=@file;" command.CommandText = sqlstatement command.Parameters.AddWithValue("@file", filename) Dim buf() As Byte 'This gets the file from the database' reader = command.ExecuteReader 'The following should get the file back to its original form' buf = reader.GetValue(0) 'This is go into the Safe and retrieve file'
-
Am I extracting the blob file correctly?
Private Function decryption()
'This is function is the same as encryption with just a few changes' 'loading the xml document' Dim key As Byte() Dim IV As Byte() 'The hardcoded password goes here' 'This is a section just in case you want to a password to your encrypted files' key = keyencryption(LoginForm.Password\_TextBox.Text) IV = IVCreation(LoginForm.Password\_TextBox.Text) 'if there is an error in the application. A error message will be displayed' Try 'checking to make sure the text box isn't null' If (Decrypt\_TextBox.Text = "") Then MessageBox.Show("Need to put in the file location or select file in grid for decryption") Else 'declaring string for file' Dim filename As String 'Getting the file name that is selected' filename = getFilename() 'Starting to abstract the data from the database' database.ConnectionString = "Data Source = FileVault.db3;" database.Open() Dim command As SQLite.SQLiteCommand Dim sqlstatement As String command = database.CreateCommand 'The following will get the bytes of the file' Dim filesize As Integer sqlstatement = "SELECT FileSize From Vault WHERE FileName=@file;" command.CommandText = sqlstatement command.Parameters.AddWithValue("@file", filename) Dim reader As SQLite.SQLiteDataReader reader = command.ExecuteReader filesize = reader.GetValue(0) reader.Close() MessageBox.Show(filesize) Dim data(filesize) As Byte 'The following should get the data' sqlstatement = "SELECT FileData FROM Vault WHERE FileName=@file;" command.CommandText = sqlstatement command.Parameters.AddWithValue("@file", filename) Dim buf() As Byte 'This gets the file from the database' reader = command.ExecuteReader 'The following should get the file back to its original form' buf = reader.GetValue(0) 'This is go into the Safe and retrieve file'
-
Am I extracting the blob file correctly?
Private Function decryption()
'This is function is the same as encryption with just a few changes' 'loading the xml document' Dim key As Byte() Dim IV As Byte() 'The hardcoded password goes here' 'This is a section just in case you want to a password to your encrypted files' key = keyencryption(LoginForm.Password\_TextBox.Text) IV = IVCreation(LoginForm.Password\_TextBox.Text) 'if there is an error in the application. A error message will be displayed' Try 'checking to make sure the text box isn't null' If (Decrypt\_TextBox.Text = "") Then MessageBox.Show("Need to put in the file location or select file in grid for decryption") Else 'declaring string for file' Dim filename As String 'Getting the file name that is selected' filename = getFilename() 'Starting to abstract the data from the database' database.ConnectionString = "Data Source = FileVault.db3;" database.Open() Dim command As SQLite.SQLiteCommand Dim sqlstatement As String command = database.CreateCommand 'The following will get the bytes of the file' Dim filesize As Integer sqlstatement = "SELECT FileSize From Vault WHERE FileName=@file;" command.CommandText = sqlstatement command.Parameters.AddWithValue("@file", filename) Dim reader As SQLite.SQLiteDataReader reader = command.ExecuteReader filesize = reader.GetValue(0) reader.Close() MessageBox.Show(filesize) Dim data(filesize) As Byte 'The following should get the data' sqlstatement = "SELECT FileData FROM Vault WHERE FileName=@file;" command.CommandText = sqlstatement command.Parameters.AddWithValue("@file", filename) Dim buf() As Byte 'This gets the file from the database' reader = command.ExecuteReader 'The following should get the file back to its original form' buf = reader.GetValue(0) 'This is go into the Safe and retrieve file'
crain1981 wrote:
It keeps saying that the file length is invalid
where? in which line?
crain1981 wrote:
for all lengths
what does that mean? :confused:
Luc Pattyn [Forum Guidelines] [My Articles] [My CP bug tracking] Nil Volentibus Arduum
Season's Greetings to all CPians.
-
crain1981 wrote:
It keeps saying that the file length is invalid
where? in which line?
crain1981 wrote:
for all lengths
what does that mean? :confused:
Luc Pattyn [Forum Guidelines] [My Articles] [My CP bug tracking] Nil Volentibus Arduum
Season's Greetings to all CPians.
-
No matter the file length it gives me this error. It does this at crypto.close(). I've googled around and still is...
-
No matter the file length it gives me this error. It does this at crypto.close(). I've googled around and still is...
A few statements: 1. I don't know why you are storing the file size; you sure don't need it to store or retrieve the file data. 2. If the crypto code is unhappy about the file size or file data, then the size or data are probably wrong and the problem is NOT in encryption. 3. As long as you fail to store and retrieve binary data, it makes no sense to complicate things with encryption/decryption. First create methods that deal with arbitrary blobs; then add some methods that handles encryption. So start with a text file, think of it as binary data, store it in a blob, retrieve the blob, store it in a new file, and compare both files. And don't mix separate functions into a single method. 4. Don't create a bunch of code, and then discover it doesn't work; you are wasting your time. Write a small bit of code, and check it works absolutely fine. Then add some, test, fix, and repeat. 5. This has been going on since medio December; all it takes is four methods, each less than 20 lines of code. 6. Suggestion: if you need only one field, use ExecuteScalar. :)
Luc Pattyn [Forum Guidelines] [My Articles] [My CP bug tracking] Nil Volentibus Arduum
Season's Greetings to all CPians.
-
A few statements: 1. I don't know why you are storing the file size; you sure don't need it to store or retrieve the file data. 2. If the crypto code is unhappy about the file size or file data, then the size or data are probably wrong and the problem is NOT in encryption. 3. As long as you fail to store and retrieve binary data, it makes no sense to complicate things with encryption/decryption. First create methods that deal with arbitrary blobs; then add some methods that handles encryption. So start with a text file, think of it as binary data, store it in a blob, retrieve the blob, store it in a new file, and compare both files. And don't mix separate functions into a single method. 4. Don't create a bunch of code, and then discover it doesn't work; you are wasting your time. Write a small bit of code, and check it works absolutely fine. Then add some, test, fix, and repeat. 5. This has been going on since medio December; all it takes is four methods, each less than 20 lines of code. 6. Suggestion: if you need only one field, use ExecuteScalar. :)
Luc Pattyn [Forum Guidelines] [My Articles] [My CP bug tracking] Nil Volentibus Arduum
Season's Greetings to all CPians.
- I figured that out already 2) Pin pointed that problem 3) Never dealt with databases before 4) NEVER did that and have constantly repeated testing... I'm always encountering one error. 5) SMDH... I ain't even going to respond there.... this is different direction than before. 6) Thanks for the suggestion... With little experience inserting into the database and no clue on how to extract the file is where my problem is.