إعداد نوع التشفير القوي باستخدام C++

تطبيق التشفير مع مايكروسوفت إكسل

لتنفيذ تشفير الملف في مايكروسوفت إكسل (مثلاً 2007):

١. من قائمة الأدوات, حدد خيارات. ١. حدد علامة التبويب الأمان. ١. أدخل قيمة لحقل كلمة المرور للفتح.

  1. انقر على متقدم. ١. اختر نوع التشفير وقم بتأكيد كلمة المرور.

تطبيق التشفير مع Aspose.Cells

تطبيق الشفرة أدناه يطبق تشفيرًا قويًا على ملف ويعين كلمة مرور.

#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;

int main()
{
    Aspose::Cells::Startup();

    // Source directory path
    U16String srcDir(u"..\\Data\\01_SourceDirectory\\");

    // Output directory path
    U16String outDir(u"..\\Data\\02_OutputDirectory\\");

    // Path of input excel file
    U16String inputFilePath = srcDir + u"Book1.xlsx";

    // Path of output excel file
    U16String outputFilePath = outDir + u"encryptedBook1.out.xls";

    // Create workbook
    Workbook workbook(inputFilePath);

    // Specify Strong Encryption type (RC4, Microsoft Strong Cryptographic Provider)
    workbook.SetEncryptionOptions(EncryptionType::StrongCryptographicProvider, 128);

    // Password protect the file
    workbook.GetSettings().SetPassword(u"1234");

    // Save the Excel file
    workbook.Save(outputFilePath);

    std::cout << "File encrypted and saved successfully!" << std::endl;

    Aspose::Cells::Cleanup();
}