Node.js kullanarak C++ üzerinden Sertifika ile Dijital Olarak Bir VBA Kod Projesini İmzala

Node.js ile Sertifika kullanarak VBA Kod Projesini Dijital Olarak İmzala

Aşağıdaki örnek kod, VbaProject.sign(DigitalSignature) yönteminin nasıl kullanılacağını gösterir. İşte örnek kodun giriş ve çıkış dosyaları. Bu kodu test etmek için herhangi bir Excel dosyası ve herhangi bir sertifika kullanabilirsiniz.

  • Örnek Excel dosyası](5115028.xlsm) örnek kodda kullanılan.
  • Örnek pfx dosyası Dijital İmza oluşturmak için. Bu kodu çalıştırmak için lütfen bilgisayarınıza kurun. Şifresi 1234’tür.
  • Çıktı Excel dosyası örnek kod tarafından oluşturulan.
const fs = require("fs");
const path = require("path");
const AsposeCells = require("aspose.cells.node");

// Set up paths
const sourceDir = path.join(__dirname, "data");
const outputDir = path.join(__dirname, "output");
const pfxPath = path.join(sourceDir, "sampleDigitallySignVbaProjectWithCertificate.pfx");
const workbookPath = path.join(sourceDir, "sampleDigitallySignVbaProjectWithCertificate.xlsm");

// Set Digital Signature
const password = "1234";
const comment = "Signing Digital Signature using Aspose.Cells";
const digitalSignature = new AsposeCells.DigitalSignature(fs.readFileSync(pfxPath), password, comment, new Date());

// Create workbook object from excel file
const workbook = new AsposeCells.Workbook(workbookPath);

// Sign VBA Code Project with Digital Signature
workbook.getVbaProject().sign(digitalSignature);

// Save the workbook
workbook.save(path.join(outputDir, "outputDigitallySignVbaProjectWithCertificate.xlsm"));