Security in cryptography
Cryptography 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 project
2.Add the following assembly on the page
using
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);
}
}
}
4.Now create a text file in the folder D:\New Folder (2)\ConsoleApplication4\ConsoleApplication4\bin\Debug (My text file path) with some text which you want to encrypt .
Now start debugging, you will see a testDes.txt folder automatically generated in the folder that is encrypted folder.
NikolayPosted Aug 24, 2010, 2:34 AM
Nice, but everybody should know that DES is now considered insecure. Using of not yet compromised algorithms is strongly recommended. See http://en.wikipedia.org/wiki/Data_Encryption_Standard
Andy BotschPosted Aug 17, 2010, 1:06 PM
Can this method also be used to encrypt .exe For example if I wanted to crypt a malicious file program of some sort and make it where it can still run, but it is not detected by antivirus.
Koteswararao MallisettiPosted Aug 17, 2010, 8:57 AM
ok i am already test it ,it will also work fine good what about public key algorithms if have any code send me
Koteswararao MallisettiPosted Aug 17, 2010, 7:03 AM
it work fine but where is the decryption code i need