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. General Programming
  3. Visual Basic
  4. Encrypt File using User Supplied Password

Encrypt File using User Supplied Password

Scheduled Pinned Locked Moved Visual Basic
securityhelptutorial
1 Posts 1 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.
  • H Offline
    H Offline
    hkinser9
    wrote on last edited by
    #1

    Hello everyone. I've read several articles on the internet in trying to figure this out; however, those article seem a bit over my head apparently and I can't seem to find a code example that is simple and to the point to implement. I'm coding a password manager program in vb 2005. All that is left to do is obtain a password from the user the first time they start the program, and use that password as the encryption key in creating the file that will hold the data from the listview control. For now, the login form is simply taking the password the user enters and encrypting it inside a separate file for now as you will see below - the file itself is not encrypted. I have all the forms complete and the listview data is writing to a currently unencrypted file for now. I just want to make it all one file with the user password being the key to encrypt it all. Here is the login code I'm using if we can somehow modify it to do what I'm looking for: If txtUserPsw.Text = txtPswVerify.Text And Me.txtPswVerify.Text.Length >= 8 Then Try ' Obtain a FileStream object. Dim aFileStream As New FileStream(AppPath(False) & "\passsafe.bin", FileMode.Create) ' Obtain a BinaryWriter object. Dim aBinaryWriter As New BinaryWriter(aFileStream) ' Encrypt the new password and binary write to a binary file. aBinaryWriter.Write(EncryptPassword.EncryptString(Me.txtPswVerify.Text)) ' Close the FileStream and the BinaryWriter objects. aFileStream.Close() aBinaryWriter.Close() ' Message user. MessageBox.Show("Password was encrypted and saved. Don't forget it!") 'Display Main form (Frmlogin) Dim safe As New frmSafe 'Hides login form Me.Visible = False safe.ShowDialog() 'disposes login form on exit of main form 'Application.Exit() Me.Close() Catch ex As Exception ' Message user. MessageBox.Show("Password was not saved. ERROR: " & ex.Message) End Try End If Thanks everyone! Sincerely, Harold

    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