Sertifika ile bir VBA Kod Projesini Dijital Olarak İmzalama

C# ile bir VBA Kod Projesini Sertifika ile Dijital Olarak İmzalama

Aşağıdaki örnek kod, Workbook.VbaProject.Sign() yöntemini nasıl kullanacağınızı göstermektedir. Örnek kodun girdi ve çıktı dosyaları aşağıda verilmiştir. Bu kodu test etmek için herhangi bir excel dosyası ve 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.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
string password = "1234";
string pfxPath = sourceDir + "sampleDigitallySignVbaProjectWithCertificate.pfx";
string comment = "Signing Digital Signature using Aspose.Cells";
// Set Digital Signature
DigitalSignature digitalSignature = new DigitalSignature(File.ReadAllBytes(pfxPath), password, comment, DateTime.Now);
// Create workbook object from excel file
Workbook workbook = new Workbook(sourceDir + "sampleDigitallySignVbaProjectWithCertificate.xlsm");
// Sign VBA Code Project with Digital Signature
workbook.VbaProject.Sign(digitalSignature);
// Save the workbook
workbook.Save(outputDir + "outputDigitallySignVbaProjectWithCertificate.xlsm");