Vitajte na [www.pocitac.win] Pripojiť k domovskej stránke Obľúbené stránky
Otvorte aplikáciu Microsoft Visual C # Express a kliknite na tlačidlo " Nový projekt ... " na ľavom paneli obrazovky . Double - kliknite na " Console Application " , v strednej table okna " Nový projekt " .
2
Stlačte tlačidlo " Ctrl " + " " a stlačte tlačidlo " Delete " pre vymazanie existujúci kód .
3
skopírujte a vložte nasledujúci kód do modulu " Program.cs " :
using System ;
pomocou System.IO ;
pomocou System.Security ;
pomocou System.Security.Cryptography ;
pomocou System.Runtime.InteropServices ;
pomocou System.Text ;
namespace CSEncryptDecrypt
{
class Class1
{
[ System.Runtime.InteropServices.DllImport ( " KERNEL32.DLL " , EntryPoint = " RtlZeroMemory " ) ]
public static extern bool ZeroMemory ( IntPtr cieľ , int dĺžka ) ;
static string GenerateKey ( )
{
DESCryptoServiceProvider desCrypto = ( DESCryptoServiceProvider ) DESCryptoServiceProvider.Create ( ) ;
vrátiť ASCIIEncoding.ASCII.GetString ( desCrypto.Key ) ;
}
static void EncryptFile ( string sInputFilename ,
string sOutputFilename ,
string Skey )
{
FileStream fsInput = new FileStream ( sInputFilename ,
FileMode.Open ,
FileAccess . Prečítajte ) ;
FileStream fsEncrypted = 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 ,
desencrypt ,
CryptoStreamMode.Write ) ;
byte [ ] bytearrayinput = new byte [ fsInput.Length ] ;
fsInput.Read ( bytearrayinput , 0 , bytearrayinput.Length ) ;
cryptostream.Write ( bytearrayinput , 0 , void main ( )
{
string sSecretKey ;
sSecretKey = GenerateKey ( ) ;
GCHandle GCH = GCHandle.Alloc ( sSecretKey , sSecretKey.Length * 2 ) ;
gch.Free ( ) ;
}
}
}
4
upravte nasledujúci riadok kódu a zadajte názov súboru , ktorý chcete " F5 " pre spustenie programu .