C# 檔案的加密/解密(DES)
資料來源:http://www.dotblogs.com.tw/yc421206/archive/2012/04/18/71609.aspx
https://support.microsoft.com/zh-tw/kb/307010
using System; using System.Collections.Generic; using System.Linq; using System.Text;
using System.IO;//FILE using System.Security.Cryptography;//DESCryptoServiceProvider namespace Console_CS_Encrypt_desDecrypt { class Program { public { if { return; } if { return; }
DESCryptoServiceProvider byte[] byte[]
des.Key = key; des.IV = iv;
using using { //檔E案¡Ñ加D[密ÓK byte[]
using { cs.Write(dataByteArray, cs.FlushFinalBlock(); } } } public { if { return; } if { return; }
DESCryptoServiceProvider byte[] byte[]
des.Key = key; des.IV = iv;
using using { byte[] using { cs.Write(dataByteArray, cs.FlushFinalBlock(); } } } static { string string string desDecryptFile(encryptFile, Pause(); } public static void Pause() { Console.Write(“Press any key to continue . . . “); Console.ReadKey(true); } } }
|