Справочник по C#

    Исходники по языку программирования CSharp

    Шифрование файлов: Справочник по C#

    /
    /
    /
    39 Views


    private static void EncryptFile(string inputFile, string outputFile, string skey)
    {
    RijndaelManaged aes = new RijndaelManaged();
    
    try
    {
    byte[] key = ASCIIEncoding.UTF8.GetBytes(skey);
    using (FileStream fsCrypt = new FileStream(outputFile, FileMode.Create))
    {
    using (CryptoStream cs = new CryptoStream(fsCrypt, aes.CreateEncryptor(key, key), CryptoStreamMode.Write))
    {
    using (FileStream fsIn = new FileStream(inputFile, FileMode.Open))
    {
    int data;
    while ((data = fsIn.ReadByte()) != -1)
    {
    cs.WriteByte((byte)data);
    }
    aes.Clear();
    }
    }
    }
    }
    catch (Exception ex)
    {
    Console.WriteLine(ex.Message);
    aes.Clear();
    }
    }

    Источник www.fluxbytes.com

    Шифрование файлов: Справочник по C#

    0.00 (0%) 0 votes

    moyadcode13
    • Facebook
    • Twitter
    • Google+
    • Linkedin
    • Pinterest
    moyadcode10
    moyadcode11
    moyadcode9