Einstellung eines starken Verschlüsselungstyps mit C++

Verschlüsselung mit Microsoft Excel anwenden

Um die Dateiverschlüsselung in Microsoft Excel (zum Beispiel 2007) zu implementieren:

  1. Wählen Sie im Extras-Menü die Option Optionen aus.
  2. Wählen Sie den Tab Sicherheit aus.
  3. Geben Sie einen Wert für das Feld Kennwort zum Öffnen ein.
  4. Klicken Sie auf Erweitert.
  5. Wählen Sie den Verschlüsselungstyp aus und bestätigen Sie das Passwort.

Verschlüsselung mit Aspose.Cells anwenden

Die unten stehenden Codebeispiele wenden eine starke Verschlüsselung auf eine Datei an und setzen ein Passwort.

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