Définir un type de chiffrement fort avec C++

Application du chiffrement avec Microsoft Excel

Pour implémenter le chiffrement de fichier dans Microsoft Excel (par exemple 2007) :

  1. Dans le menu Outils, sélectionnez Options.
  2. Sélectionnez l’onglet Sécurité.
  3. Entrez une valeur pour le champ Mot de passe pour ouvrir.
  4. Cliquez sur Avancé.
  5. Choisissez le type de chiffrement et confirmez le mot de passe.

Application du chiffrement avec Aspose.Cells

Les exemples de code ci-dessous appliquent un chiffrement fort sur un fichier et définissent un mot de passe.

#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();
}