Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does ItextSharp 5.4.5 support 256 bit encryption?

Tags:

.net

itext

Does ItextSharp 5.4.5 support 256 bit encryption ??

i did my research but didn't find anything about 256 bit encryption. All people are saying itext java version support AES 256 bit encryption.

like image 998
user3208086 Avatar asked Nov 27 '25 14:11

user3208086


1 Answers

Yes, here's a short example that takes a PDF and encrypts a copy of it using 256-bit AES encryption:

var openDialog = new OpenFileDialog();
openDialog.DefaultExt = "pdf";
if (openDialog.ShowDialog() == true)
{
    using (var input = openDialog.OpenFile())
    {
        var saveDialog = new SaveFileDialog();
        saveDialog.DefaultExt = "pdf";
        if (saveDialog.ShowDialog() == true)
        {
            using (var reader = new PdfReader(input)) 
            {
                using (var output = saveDialog.OpenFile())
                {
                    PdfEncryptor.Encrypt(\
                        reader, output, 
                        PdfWriter.ENCRYPTION_AES_256, 
                        "password", "password", 
                        PdfWriter.ALLOW_PRINTING);
                }
            }
        }

    }
}
like image 59
Chris Pietschmann Avatar answered Nov 30 '25 04:11

Chris Pietschmann



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!