public static void KriptoFile(string dosyalar, string password = "******", string uzanti = ".uzanti") { System.Security.Cryptography.Rfc2898DeriveBytes rfc = new System.Security.Cryptography.Rfc2898DeriveBytes(password, @byte); System.IO.FileStream fs = new System.IO.FileStream(dosyalar + uzanti, System.IO.FileMode.Create); System.Security.Cryptography.RijndaelManaged rm = new System.Security.Cryptography.RijndaelManaged(); System.Security.Cryptography.CryptoStream cs = new System.Security.Cryptography.CryptoStream(fs, rm.CreateEncryptor(rfc.GetBytes(32), rfc.GetBytes(16)), System.Security.Cryptography.CryptoStreamMode.Write); System.IO.FileStream fs2 = new System.IO.FileStream(dosyalar, System.IO.FileMode.Open, System.IO.FileAccess.Read); int temp; temp = fs2.ReadByte(); while (temp != -1) { cs.WriteByte((byte)temp); temp = fs2.ReadByte(); } //Close işlemleri , silmeyin. Mümkünse hiç bi' yeri ellemeyin. cs.Close(); fs.Close(); fs2.Close(); System.IO.File.Delete(dosyalar); //Bu biraz farklı , ilk önce dosyaların kopyasını oluşturup şifreler. Daha sonra siler. }
public override void WriteByte(byte value) { _cryptoStream.WriteByte(value); }