Security in cryptographyCryptography play important role in Security. Using Cryptography we can Encrypt and Decrypt the information in the Coded form.How we Encrypt the File using DES (Data Encryption standard) algorithm. 1.Open visual studio and create a project2.Add the following assembly on the pageusing Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Security;
using System.Security.Cryptography;
using System.Text;
using System.IO;
3.Now write the Code in the Page
public class Tester
{
public static void Main()
{
try
{
DESCryptoServiceProvider myDESProvider = new DESCryptoServiceProvider();
myDESProvider.Key = ASCIIEncoding.ASCII.GetBytes("12345678");
myDESProvider.IV = ASCIIEncoding.ASCII.GetBytes("12345678");
ICryptoTransform myICryptoTransform = myDESProvider.CreateEncryptor(myDESProvider.Key, myDESProvider.IV);
FileStream ProcessFileStream = new FileStream("test.txt", FileMode.Open, FileAccess.Read);
FileStream ResultFileStream = new FileStream("testDes.txt", FileMode.Create, FileAccess.Write);
CryptoStream myCryptoStream = new CryptoStream(ResultFileStream, myICryptoTransform, CryptoStreamMode.Write);
byte[] bytearrayinput = new byte[ProcessFileStream.Length];
ProcessFileStream.Read(bytearrayinput, 0, bytearrayinput.Length);
myCryptoStream.Write(bytearrayinput, 0, bytearrayinput.Length);
myCryptoStream.Close();
ProcessFileStream.Close();
ResultFileStream.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}Read more: C# Corener
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Security;
using System.Security.Cryptography;
using System.Text;
using System.IO;
3.Now write the Code in the Page
public class Tester
{
public static void Main()
{
try
{
DESCryptoServiceProvider myDESProvider = new DESCryptoServiceProvider();
myDESProvider.Key = ASCIIEncoding.ASCII.GetBytes("12345678");
myDESProvider.IV = ASCIIEncoding.ASCII.GetBytes("12345678");
ICryptoTransform myICryptoTransform = myDESProvider.CreateEncryptor(myDESProvider.Key, myDESProvider.IV);
FileStream ProcessFileStream = new FileStream("test.txt", FileMode.Open, FileAccess.Read);
FileStream ResultFileStream = new FileStream("testDes.txt", FileMode.Create, FileAccess.Write);
CryptoStream myCryptoStream = new CryptoStream(ResultFileStream, myICryptoTransform, CryptoStreamMode.Write);
byte[] bytearrayinput = new byte[ProcessFileStream.Length];
ProcessFileStream.Read(bytearrayinput, 0, bytearrayinput.Length);
myCryptoStream.Write(bytearrayinput, 0, bytearrayinput.Length);
myCryptoStream.Close();
ProcessFileStream.Close();
ResultFileStream.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}Read more: C# Corener
1 comments:
Thank you for some other excellent post. The place
else may anyone get that type of info in such a perfect manner of writing?
I have a presentation next week, and I'm on the search for such information.
Have a look at my blog post :: Highly recommended Internet site
Post a Comment