|
Screen shot

Fig 1 : Secure File Main Screen

Fig 2 : Secure File Start Encryption

Fig 2 : Secure File Start Decryption
Logics
Step 1 :
First Select a file convert the file content into Byte array
for that we create FileStream object and pass this
FileStream object to BinaryReader to get the raw bytes.
Dim Fs
As
New System.IO.FileStream(FileName,
System.IO.FileMode.Open)
Dim bn
As
New System.IO.BinaryReader(Fs)
Step 2 :
Now create a DataTable to a DataSet to store all the details
including file name, binary content and encrypted password
Dim DsImg
As
New DataSet
Dim Dt
As
New DataTable("Images")
Dt.Columns.Add(New
DataColumn("sysid", _
System.Type.GetType("System.String")))
Dt.Columns.Add(New
DataColumn("filename", _
System.Type.GetType("System.String")))
Dt.Columns.Add(New
DataColumn("image", _
System.Type.GetType("System.Byte[]")))
Dt.Columns.Add(New
DataColumn("filetag", _
System.Type.GetType("System.String")))
DsImg.Tables.Add(Dt)
Step 3 :
Now add the data to the DtataTable and write XML file with
*.sp2p extension, encrypt password with custom PK
encryption. If you want you can encrypt the binary content,
I left this to the users.
Dim Dr
As DataRow
Dr = DsImg.Tables("images").NewRow
Dr("sysid") =
Now.ToString
Dr("filename") =
TxtFileName.Text
Dr("image") =
bn.ReadBytes(Int(bn.BaseStream.Length))
Dr("filetag") =
StrEncrypt(TxtPassword.Text)
DsImg.Tables("images").Rows.Add(Dr)
'>>> write xml file from
dataset with binary content
DsImg.WriteXml(TxtFileName.Text &
".sp2p")
Step 4 :
For decryption we load the xml file into dataset, then
decrypt the password to check with supplied password, If it
match. Read content from dataset into byte array and write
into file stream, remove .sp2p from the final decrypted
file.
Dim
Content As
Byte()
Content = DsImg.Tables(0).Rows(0).Item(2)
Dim Fs
As
New System.IO.FileStream(FileName,
System.IO.FileMode.Create)
Fs.Write(Content, 0, Content.Length)
Fs.Close()
Download the source code and project files |