Ställa in stark krypteringstyp med C++

Tillämpa kryptering med Microsoft Excel

För att implementera filkryptering i Microsoft Excel (till exempel 2007):

  1. Från menyn Verktyg väljer du Alternativ.
  2. Välj fliken Säkerhet.
  3. Ange ett värde för fältet Lösenord för att öppna.
  4. Klicka på Avancerat.
  5. Välj krypteringstyp och bekräfta lösenordet.

Tillämpa kryptering med Aspose.Cells

Kodexemplen nedan tillämpar stark kryptering på en fil och anger ett lösenord.

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