Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Database Extraction Help

Database Extraction Help

Scheduled Pinned Locked Moved Database
helpcssdatabasesqlitesecurity
7 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    crain1981
    wrote on last edited by
    #1

    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'
    
    C L 2 Replies Last reply
    0
    • C crain1981

      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'
      
      C Offline
      C Offline
      crain1981
      wrote on last edited by
      #2

      Does anyone know what I'm doing wrong?

      1 Reply Last reply
      0
      • C crain1981

        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'
        
        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        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.

        C 1 Reply Last reply
        0
        • L Luc Pattyn

          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.

          C Offline
          C Offline
          crain1981
          wrote on last edited by
          #4

          No matter the file length it gives me this error. It does this at crypto.close(). I've googled around and still is...

          C L 2 Replies Last reply
          0
          • C crain1981

            No matter the file length it gives me this error. It does this at crypto.close(). I've googled around and still is...

            C Offline
            C Offline
            crain1981
            wrote on last edited by
            #5

            I've also taken out the encryption and found out that the problem still exists without encryption.

            1 Reply Last reply
            0
            • C crain1981

              No matter the file length it gives me this error. It does this at crypto.close(). I've googled around and still is...

              L Offline
              L Offline
              Luc Pattyn
              wrote on last edited by
              #6

              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.

              C 1 Reply Last reply
              0
              • L Luc Pattyn

                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.

                C Offline
                C Offline
                crain1981
                wrote on last edited by
                #7
                1. 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.
                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups