Aprire Microsoft Visual C # Express e fare clic su " Nuovo progetto ... " nel riquadro di sinistra del vostro schermo . Fare doppio clic su " Applicazione console " nel riquadro centrale della finestra "Nuovo progetto" . 
 2 Premere 
 "Ctrl " + " A" e premere " Delete" per cancellare il codice esistente . 
 
 3 
 Copia e incolla il seguente codice al modulo " Program.cs " : 
 
 using System; 
 
 using System.IO; 
 
 utilizzando System.Security ; 
 
 utilizzando System.Security.Cryptography ; 
 
 utilizzando System.Runtime.InteropServices ; 
 
 utilizzando System.Text ; 
 namespace 
 CSEncryptDecrypt 
 
 { 
 
 classe Class1 
 
 { 
 
 [ System.Runtime.InteropServices.DllImport ( " KERNEL32.DLL " , EntryPoint = " RtlZeroMemory " ) ] 
 
 public static extern bool ZeroMemory ( IntPtr Destinazione , int lunghezza) ; 
 
statico stringa GenerateKey ( ) per
 { 
 
 DESCryptoServiceProvider desCrypto = ( DESCryptoServiceProvider ) DESCryptoServiceProvider.Create (); 
 
 ASCIIEncoding.ASCII.GetString ritorno ( desCrypto.Key ) ; 
 
 } 
 
statico EncryptFile void ( sInputFilename stringa , Stati
sOutputFilename stringa , Stati
stringa sKey ) per
 { 
 
fsInput FileStream = new FileStream ( sInputFilename , Stati
FileMode.Open , Stati
 FileAccess . Read) ; 
 
 fsEncrypted FileStream = new DES = new DESCryptoServiceProvider ( ) ; 
 
 DES.Key = ASCIIEncoding.ASCII.GetBytes ( sKey ) ; 
 
 DES.IV = ASCIIEncoding.ASCII.GetBytes ( sKey ) ; 
 
 ICryptoTransform desencrypt = DES.CreateEncryptor (); 
 
CryptoStream CryptoStream = new CryptoStream ( fsEncrypted , Stati
desencrypt , Stati
 CryptoStreamMode.Write ) ; 
 
 byte [ ] bytearrayinput = new byte [ fsInput.Length ] ; 
 
 fsInput.Read ( bytearrayinput , 0 , bytearrayinput.Length ) ; 
 
 cryptostream.Write ( bytearrayinput , 0 , void main ( ) { 
 
 
 
 stringa sSecretKey ; 
 
 sSecretKey = GenerateKey (); 
 
 GCHandle gch = GCHandle.Alloc ( sSecretKey , sSecretKey.Length * 2) ; 
 
 gch.Free (); } 
 
 
 
 } 
 
 } 
 4 
 modificare la seguente riga di codice e digitare il nome del file che si desidera "F5" per eseguire il programma . 
 
              
Programmazione © www.354353.com