Save Data's from Database table to a DES Encrypted file in VB.net

Save Data from Database table to a DES Encrypted file in VB.net



Abstract :


Save Data's from Database table to a DES Encrypted file in VB.net

Description:


To Save Data's from Database table to a DES Encrypted file in VB.net.

Code:




Imports System
Imports System.Xml
Imports System.Xml.Schema
Imports System.IO
Imports System.Data.OleDb
Imports System.Data.Common
Imports System.Data.SqlClient
Imports System.Data
Imports System.Security
Imports System.Security.Cryptography


Public Class EncryptedData

Shared Sub Main()
Dim fso As FileStream = New FileStream("DSencrypted.dat",FileMode.Create, FileAccess.Write)
Dim DS1 As DataSet = New DataSet()
Dim Connection As SqlConnection = New SqlConnection("Server=(local)\SQLEXPRESS;Initial Catalog=DatabaseName;Integrated Security=SSPI;UID=sa;PWD=")
Connection.Open()
Dim Adap As SqlDataAdapter = New SqlDataAdapter("SELECT * FROM Emp_master", Connection)
Adap .Fill(DS1, "Emp_master")

Dim DES As DESCryptoServiceProvider = New DESCryptoServiceProvider()

Dim DESencrypter As ICryptoTransform = DES.CreateEncryptor()
Dim cryptStream As CryptoStream = New CryptoStream(fso, DESencrypter, CryptoStreamMode.Write)

DS1.WriteXml(cryptStream, XmlWriteMode.WriteSchema)
cryptStream.Close()
End Sub
End Class


Comments

Author: Mrs. Meetu Choudhary Nanda04 Jul 2009 Member Level: Gold   Points : 1

Please Post Formatted Resources. I have already Told you many Times. From next time if you will post unformatted resources then they will be moved to the deleted resources. Please take care of this in future.

++
Thanks and Regards
Meetu Choudhary
Site Coordinator.



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: