Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Created February 11, 2026 17:07
Show Gist options
  • Select an option

  • Save aspose-com-gists/517701807ffb1fd41f0c42ba95e5ad16 to your computer and use it in GitHub Desktop.

Select an option

Save aspose-com-gists/517701807ffb1fd41f0c42ba95e5ad16 to your computer and use it in GitHub Desktop.
using Aspose.Imaging;
using Aspose.Imaging.FileFormats.Png;
string dataDir = @"c:\Users\USER\Downloads\templates\";
string password = "veryStr0ngPassword";
using (Aspose.Imaging.RasterImage image = (Aspose.Imaging.RasterImage)Image.Load(Path.Combine(dataDir, @"template.png")))
{
image.EmbedDigitalSignature(password); // Embeds LSB-based signature data into the image using the specified password.
image.Save(Path.Combine(dataDir, @"result.png"));
}
using (Aspose.Imaging.RasterImage image = (Aspose.Imaging.RasterImage)Image.Load(Path.Combine(dataDir, @"result.png")))
{
int signingPercentage = image.AnalyzePercentageDigitalSignature(password); // Calculates the probability (0–100%) that
// the image contains a digital signature
// generated using the specified password.
}
File.Delete(Path.Combine(dataDir, @"result.png"));
using Aspose.Imaging;
using Aspose.Imaging.FileFormats.Png;
string dataDir = @"c:\Users\USER\Downloads\templates\";
string password = "veryStr0ngPassword";
using (Aspose.Imaging.RasterImage image = (Aspose.Imaging.RasterImage)Image.Load(Path.Combine(dataDir, @"template.png")))
{
image.EmbedDigitalSignature(password); // Embeds LSB-based signature data into the image using the specified password.
image.Save(Path.Combine(dataDir, @"result.png"));
}
File.Delete(Path.Combine(dataDir, @"result.png"));
using Aspose.Imaging;
using Aspose.Imaging.FileFormats.Png;
string dataDir = @"c:\Users\USER\Downloads\templates\";
string password = "veryStr0ngPassword";
int threshold = 90;
using (Aspose.Imaging.RasterImage image = (Aspose.Imaging.RasterImage)Image.Load(Path.Combine(dataDir, @"template.png")))
{
image.EmbedDigitalSignature(password); // Embeds LSB-based signature data into the image using the specified password.
image.Save(Path.Combine(dataDir, @"result.png"));
}
using (Aspose.Imaging.RasterImage image = (Aspose.Imaging.RasterImage)Image.Load(Path.Combine(dataDir, @"result.png")))
{
bool isSigned = image.IsDigitalSigned(password); // Validates that the embedded digital signature matches
// the provided password.
}
using (Aspose.Imaging.RasterImage image = (Aspose.Imaging.RasterImage)Image.Load(Path.Combine(dataDir, @"result.png")))
{
bool isSigned = image.IsDigitalSigned(password, threshold); // Verifies that the embedded digital signature
// corresponds to the provided password based on the
// specified probability threshold.
}
File.Delete(Path.Combine(dataDir, @"result.png"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment