Hello All,
I am a student and just finished my first programming class as part of a CS Bachelors degree program. For my final project I did made a program that simply encrypted a file and allowed the user to attach it to an email. I used the trial version of the DidiSoft OpenPGP library for .NET. I'll include the code, just for kicks. Would love to have some comments. There are some things I really struggled with, like allowing the user to choose a password. That seems more like a VB specific problem.
My real question is this. Why do I use this library instead of the importing the cryptographic names spaces? They seem similar, I am really curious. Is it because it uses openPGP? It seems like the best thing out there. Wish I could work with it more. Here's some of my code. It was way outside the scope of my project and the material we addressed in class. I really learned a lot from doing it, but someone else could have whipped this up in a flash I think. It took me many hours and lots of reading. I probably spent close to 40 hours researching this and getting it to work. Unfortunately my program will break in a few days after my trial expires! I'm still working on it anyway, not sure why.
Anyway, thanks in advance.
Here's the code:
Dim pgp As New PGPLib()
' Specify should the output be ASCII or binary
Dim asciiArmor As Boolean = True
REM This allows the user to choose an existing file, encrypt the file and then
Using ofd As New OpenFileDialog With {.Filter = "Text Files (*.txt)|*.txt"}
If ofd.ShowDialog() = DialogResult.OK Then
Using sfd As New SaveFileDialog With {.Filter = "Text Files (*.txt)|*.pgp"}
If sfd.ShowDialog() = DialogResult.OK Then
pgp.EncryptFilePBE(New FileInfo(ofd.FileName), _
"password", _
New FileInfo(sfd.FileName), _
asciiArmor)
strEncryptedFileList = sfd.FileName
CryptoActions.lstFiles.Items.Add(strEncryptedFileList)
End If
End Using
End If
End Using
FileListTest = True