Configurar tipo de cifrado fuerte con C++

Aplicar cifrado con Microsoft Excel

Para implementar el cifrado de archivos en Microsoft Excel (por ejemplo 2007):

  1. Desde el menú Herramientas, selecciona Opciones.
  2. Selecciona la pestaña Seguridad.
  3. Ingresa un valor para el campo Contraseña para abrir.
  4. Haz clic en Avanzado.
  5. Elige el tipo de cifrado y confirma la contraseña.

Aplicar cifrado con Aspose.Cells

Los ejemplos de código a continuación aplican cifrado fuerte en un archivo y establecen una contraseña.

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