// Copyright (C) 2003-2026, Foxit Software Inc..
// All Rights Reserved.
//
// http://www.foxitsoftware.com
//
// The following code is copyrighted and contains proprietary information and trade secrets of Foxit Software Inc..
// You cannot distribute any part of Foxit PDF SDK to any third party or general public,
// unless there is a separate license agreement with Foxit Software Inc. which explicitly grants you such rights.
//
// This file contains an example to demonstrate how to use Foxit PDF SDK to do encryption and decryption for a PDF file
// by using password security method, custom security method, Foxit DRM security method, certificate security method
// or Microsoft RMS security method.

using System;
using System.IO;
using System.Text;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Security.Cryptography.Pkcs;
using System.Runtime.InteropServices;

using foxit.common;
using foxit.pdf;

namespace securityCS
{
    class CertificateSecurityEvent : CertificateSecurityCallback
    {
        private X509Certificate2Collection x509s = new X509Certificate2Collection();

        public CertificateSecurityEvent(string filePath, string password)
        {
            var x509 = new X509Certificate2(filePath, password);
            x509s.Add(x509);
        }

        public override void Release()
        {
        }

        public override void Dispose()
        {
        }

        public override string GetDecryptionKey(IntPtr envelope_buffer, int envelope_length)
        {
            if (envelope_length == 0)
                return "";
            byte[] envelope = new byte[envelope_length];
            Marshal.Copy(envelope_buffer, envelope, 0, envelope_length);
            var cms = new EnvelopedCms();
            cms.ContentEncryptionAlgorithm.Oid.Value = "1.2.840.113549.3.4";
            cms.Decode(envelope);
            cms.Decrypt(x509s);
            byte[] bytes = cms.Encode();
            return Encoding.Default.GetString(bytes);
        }

    }

    class CustomSecurityEvent : CustomSecurityCallback
    {
        public override void Release()
        {
        }

        public override void Dispose()
        {
        }

        public override IntPtr CreateContext(string filter, string sub_filter, string encrypt_info)
        {
            return IntPtr.Zero;
        }
        public override IntPtr DecryptData(IntPtr decryptor, IntPtr encrypted_data, int encrypted_data_len)
        {
            if (encrypted_data_len == 0)
                return IntPtr.Zero;
            byte[] data = new byte[encrypted_data_len];
            Marshal.Copy(encrypted_data, data, 0, encrypted_data_len);
            for (int i = 0; i < encrypted_data_len; i++)
            {
                data[i] += 1;
            }
            IntPtr decrypted_data = Marshal.AllocHGlobal(data.Length);
            Marshal.Copy(data, 0, decrypted_data, data.Length);
            return decrypted_data;
        }
        public override bool EncryptData(IntPtr context, int obj_num, int gen_num, IntPtr src_data, int src_data_len, IntPtr out_dst_buffer, out int out_dst_buffer_len)
        {
            byte[] data = new byte[src_data_len];
            Marshal.Copy(src_data, data, 0, src_data_len);
            for (int i = 0; i < src_data_len; i++)
            {
                data[i] -= 1;
            }
            Marshal.Copy(data, 0, out_dst_buffer, data.Length);
            out_dst_buffer_len = data.Length;
            return true;
        }
        public override string FinishDecryptor(IntPtr decryptor)
        {
            return "";
        }
        public override SecurityHandler.CipherType GetCipher(IntPtr context)
        {
            return SecurityHandler.CipherType.e_CipherAES;
        }
        public override int GetDecryptedSize(IntPtr context, int src_data_size)
        {
            return src_data_size;
        }
        public override int GetEncryptedSize(IntPtr context, int obj_num, int gen_num, IntPtr src_data, int src_data_len)
        {
            return src_data_len;
        }
        public override string GetEncryptKey(IntPtr context)
        {
            return "key";
        }
        public override int GetUserPermissions(IntPtr context, int user_permission)
        {
            return -4;
        }
        public override bool IsOwner(IntPtr context)
        {
            return true;
        }
        public override bool ReleaseContext(IntPtr context)
        {
            return true;
        }
        public override IntPtr StartDecryptor(IntPtr context, int obj_num, int gen_num)
        {
            return IntPtr.Zero;
        }
    }

    class DRMSecurityEvent : DRMSecurityCallback
    {
        string fileID;
        string initialKey;

        public DRMSecurityEvent(string fileID, string initialKey)
        {
            this.fileID = fileID;
            this.initialKey = initialKey;
        }

        public override void Release()
        {
        }
        public override void Dispose()
        {
        }
        public override SecurityHandler.CipherType GetCipherType(PDFDoc document, string sub_filter)
        {
            return SecurityHandler.CipherType.e_CipherAES;
        }
        public override string GetFileID(PDFDoc document, string sub_filter)
        {
            return fileID;
        }
        public override string GetInitialKey(PDFDoc document, string sub_filter)
        {
            return initialKey;
        }
        public override int GetKeyLength(PDFDoc document, string sub_filter)
        {
            return 16;
        }
        public override int GetUserPermissions(PDFDoc document, string sub_filter)
        {
            return -4;
        }
        public override bool IsOwner(PDFDoc document, string sub_filter)
        {
            return true;
        }
    }

    class RMSSecurityEvent : RMSSecurityCallback
    {
        string key;

        public RMSSecurityEvent(string key)
        {
            this.key = key;
        }

        public override void Dispose()
        {
        }

        public override void Release()
        {
        }

        public override IntPtr CreateContext(string filter, string sub_filter, string encrypt_info)
        {
            return IntPtr.Zero;
        }
        public override IntPtr DecryptData(IntPtr decryptor, IntPtr encrypted_data, int encrypted_data_len)
        {
            if (encrypted_data_len == 0)
                return IntPtr.Zero;
            byte[] data = new byte[encrypted_data_len];
            Marshal.Copy(encrypted_data, data, 0, encrypted_data_len);
            for (int i = 0; i < encrypted_data_len; i++)
            {
                data[i] += 5;
            }
            IntPtr decrypted_data = Marshal.AllocHGlobal(data.Length);
            Marshal.Copy(data, 0, decrypted_data, data.Length);
            return decrypted_data;
        }
        public override bool EncryptData(IntPtr context, int obj_num, int gen_num, IntPtr src_data, int src_data_len, IntPtr out_dst_buffer, out int out_dst_buffer_len)
        {
            byte[] data = new byte[src_data_len];
            Marshal.Copy(src_data, data, 0, src_data_len);
            for (int i = 0; i < src_data_len; i++)
            {
                data[i] -= 5;
            }
            Marshal.Copy(data, 0, out_dst_buffer, data.Length);
            out_dst_buffer_len = data.Length;
            return true;
        }
        public override string FinishDecryptor(IntPtr decryptor)
        {
            return "";
        }
        public override SecurityHandler.CipherType GetCipher(IntPtr context)
        {
            return SecurityHandler.CipherType.e_CipherAES;
        }
        public override int GetDecryptedSize(IntPtr context, int src_data_size)
        {
            return src_data_size;
        }
        public override int GetEncryptedSize(IntPtr context, int obj_num, int gen_num, IntPtr src_data, int src_data_len)
        {
            return src_data_len;
        }
        public override string GetEncryptKey(IntPtr context)
        {
            return key;
        }
        public override int GetUserPermissions(IntPtr context, int user_permission)
        {
            return -4;
        }
        public override bool IsOwner(IntPtr context)
        {
            return true;
        }
        public override bool ReleaseContext(IntPtr context)
        {
            return true;
        }
        public override IntPtr StartDecryptor(IntPtr context, int obj_num, int gen_num)
        {
            return IntPtr.Zero;
        }
    }

    class Security
    {
        const string sn = "Rew1vB0TqoMIxX444UcpScARWdhgJpsJfzmyMLR32a0+EgrCjp2NaQ==";
        const string key = "8f3g1sFttW8NAgfSNv+BvaJWy4Pp8flcm7ncNDkdvCCO4JwUFbGLyZdujReMaiplbYJwwxam3lr7uHtQaEf0xTSu8j2ZBdrZ8FS4OQkEUjOI9UEGb3Ic0GqmlP9T9OnSItOYqoZZA/OnYg5EaVP+c/ha32nUquOk+5riEdhYgINAZDdgJkPc+YSWsrfixOIROf6t34j3eRcyFnOY0MS7tSXi1AEPE0VZdyu+5bfmBSGvLI+WR5lQ+oOQR5hRGwqf990WEdBelNO7dxhZELVhEZ+/L60PpDf5y9A8qmrY6PiEU8nhqIyLpks0BxeIsYyZ3Cr82jjfbItPGyEARsIVzluBSgVMD4oGjojz8T6wGDEXUbmZH/pra94XAs8wZ28mzbmIEppWnhBqX0c6Ov8iXCfFfUZr4KNuPxMEgk4VOYTMOd70GEjGnylivw18hbn7ZpkWh2Zql+uU2HejvOgn+WHvT0HF9NhK0Xb5vH8aFkgBP92PJx8obIbxBVeeExczxvsqWufuPdXS2sPNIgMYZ2TtvqVVsiUToeGB2FQo09fzZOSH5Vi18u/siyvC3FmjeMf4+OYWPuDPNCcrb21NgcHam7XI8AAoGLTGtLLWR+fxynbBBcg2d2ZPcZ5CMFIfOBHRWCkcA0sDT3cl9nsBppHNJze/jVxHy+lREeQEA/etSIgohTGAWW3ZlpibRXqMxlmVWEPifCubbWTzQ6U54mRMpW2UghH3gvCNFNgdday3Av7EtlIJOdUuiMq3zmmd5J4Jt4C82CKnVewA0DtZ4EEtwRG9IYuLrfpuZlnjBAtoeXRV1lqUZ6BcCe0E3m9jO28sGkALuIeJQ74XG7X8lMC7lMWWQYiYD7D6G9QT6X3qV4vXJwNKRKpYc/rI+amEawTSnDYAMEaYPwtZ0rb/7BL+atsZZaI+ncebdfVfjDJZbCZAc+JnkuNlUn2xrNRuObw8h/G0lm2pNOEJ10S8R4+yplo5B1QmC2dCDhaTaW67QJPqnJPKbVmjw7i6KGBi+CDP3JnAKlOX/YUu8uk56JfeQUuGcQg/KaBMGctnchH2n1i3+oGbibhurQj22+OO66Q6mijKoCRP/QJm5WTGcO4c0iVX0B8dIlai/uv/pGU8Wps9MxysH5ViVIj56LWKuNfy1FNO9+wx4iHYnUxfW0Iccq3YJYAlOBkMv8VZIJl9aTEEFJ626LJEw/UbEBdR9CdlwnylPf4RuNW/lcGYMgq3xNVpp/bzYKwZivvQOFgMdX1tv8D33SHvAm3zrRCU+v94BJXnBi9k25fnKsc705IMwv+I6bueXA+mDnagj1oTqsWXZ0WnPAYI3WUO7sBf7XUH230wfYXnTSVhujJxiEP/2oWqi2813gtQkKwz9N2p6yT8Vsh3+BaAwwDvtOZMJKUFcabTBSL6NoouzmzwItJ4mIboT6KXaef66rs8jCU=";

        const string input_path = "../input_files/";
        const string output_path = "../output_files/";

        const string output_directory = output_path + "security/";

        private static void CreateResultFolder(string output_path)
        {
            if (!Directory.Exists(output_path))
            {
                Directory.CreateDirectory(output_path);
            }
        }

        static void CertificateSecurity(string input_file)
        {
            Random rand = new Random(23);
            byte[] seed = new byte[24];
            rand.NextBytes(seed);
            for (int i = 20; i < 24; i++)
            {
                seed[i] = (byte)0xFF;
            }

            string output_file = output_directory + "certificate_encrypt.pdf";
            using (var doc = new PDFDoc(input_file))
            {
                ErrorCode error_code = doc.Load(null);
                if (error_code != ErrorCode.e_ErrSuccess)
                {
                    Console.WriteLine("The PDFDoc " + input_file + " Error: " + error_code);
                    return;
                }
                
                // Do encryption.
                string cert_file_path = input_path + "foxit.cer";

                var cms = new EnvelopedCms(new ContentInfo(seed));
                cms.ContentEncryptionAlgorithm.Oid.Value = "1.2.840.113549.3.4";
                cms.Encrypt(new CmsRecipient(new X509Certificate2(cert_file_path)));
                byte[] bytes = cms.Encode();
    
                byte[] data = new byte[20 + bytes.Length];
                Array.Copy(seed, 0, data, 0, 20);
                Array.Copy(bytes, 0, data, 20, bytes.Length);
                SHA1 sha1 = new SHA1CryptoServiceProvider();
                byte[] initial_key = new byte[16];
                Array.Copy(sha1.ComputeHash(data), initial_key, initial_key.Length);

                byte[][] bytes_array = new byte[1][];
                bytes_array[0] = bytes;
                using (var handler = new CertificateSecurityHandler())
                {
                    using (var encrypt_data = new CertificateEncryptData())
                    {
                        encrypt_data.Set(true, SecurityHandler.CipherType.e_CipherAES,
                            bytes_array);
                        handler.Initialize(encrypt_data, initial_key);

                        doc.SetSecurityHandler(handler);
                        doc.SaveAs(output_file, (int)PDFDoc.SaveFlags.e_SaveFlagNormal);
                    }
                }
            }
            // Do decryption.
            using (var callback = new CertificateSecurityEvent(input_path + "foxit_all.pfx", "123456"))
            {
                Library.RegisterSecurityCallback("Adobe.PubSec", callback);

                using (var encrypted_doc = new PDFDoc(output_file))
                {
                    ErrorCode error_code = encrypted_doc.Load(null);
                    if (error_code != ErrorCode.e_ErrSuccess)
                    {
                        Console.WriteLine("The PDFDoc " + input_file + " Error: " + error_code);
                        return;
                    }

                    output_file = output_directory + "certificate_decrypt.pdf";
                    encrypted_doc.RemoveSecurity();
                    encrypted_doc.SaveAs(output_file, (int)PDFDoc.SaveFlags.e_SaveFlagNormal);
                }
            }
        }

        static void FoxitDRMDecrypt(string input_file)
        {
            string output_file = output_directory + "foxit_drm_encrypt.pdf";
            string file_id = "Simple-DRM-file-ID";
            string initialize_key = "8f3g1sFttW8NAgfSNv+BvaJWy4Pp8flcm7ncNDkdvCCO4JwUFbGLyZdujReMaiplbYJwwxam3lr7uHtQaEf0xTSu8j2ZBdrZ8FS4OQkEUjOI9UEGb3Ic0GqmlP9T9OnSItOYqoZZA/OnYg5EaVP+c/ha32nUquOk+5riEdhYgINAZDdgJkPc+YSWsrfixOIROf6t34j3eRcyFnOY0MS7tSXi1AEPE0VZdyu+5bfmBSGvLI+WR5lQ+oOQR5hRGwqf990WEdBelNO7dxhZELVhEZ+/L60PpDf5y9A8qmrY6PiEU8nhqIyLpks0BxeIsYyZ3Cr82jjfbItPGyEARsIVzluBSgVMD4oGjojz8T6wGDEXUbmZH/pra94XAs8wZ28mzbmIEppWnhBqX0c6Ov8iXCfFfUZr4KNuPxMEgk4VOYTMOd70GEjGnylivw18hbn7ZpkWh2Zql+uU2HejvOgn+WHvT0HF9NhK0Xb5vH8aFkgBP92PJx8obIbxBVeeExczxvsqWufuPdXS2sPNIgMYZ2TtvqVVsiUToeGB2FQo09fzZOSH5Vi18u/siyvC3FmjeMf4+OYWPuDPNCcrb21NgcHam7XI8AAoGLTGtLLWR+fxynbBBcg2d2ZPcZ5CMFIfOBHRWCkcA0sDT3cl9nsBppHNJze/jVxHy+lREeQEA/etSIgohTGAWW3ZlpibRXqMxlmVWEPifCubbWTzQ6U54mRMpW2UghH3gvCNFNgdday3Av7EtlIJOdUuiMq3zmmd5J4Jt4C82CKnVewA0DtZ4EEtwRG9IYuLrfpuZlnjBAtoeXRV1lqUZ6BcCe0E3m9jO28sGkALuIeJQ74XG7X8lMC7lMWWQYiYD7D6G9QT6X3qV4vXJwNKRKpYc/rI+amEawTSnDYAMEaYPwtZ0rb/7BL+atsZZaI+ncebdfVfjDJZbCZAc+JnkuNlUn2xrNRuObw8h/G0lm2pNOEJ10S8R4+yplo5B1QmC2dCDhaTaW67QJPqnJPKbVmjw7i6KGBi+CDP3JnAKlOX/YUu8uk56JfeQUuGcQg/KaBMGctnchH2n1i3+oGbibhurQj22+OO66Q6mijKoCRP/QJm5WTGcO4c0iVX0B8dIlai/uv/pGU8Wps9MxysH5ViVIj56LWKuNfy1FNO9+wx4iHYnUxfW0Iccq3YJYAlOBkMv8VZIJl9aTEEFJ626LJEw/UbEBdR9CdlwnylPf4RuNW/lcGYMgq3xNVpp/bzYKwZivvQOFgMdX1tv8D33SHvAm3zrRCU+v94BJXnBi9k25fnKsc705IMwv+I6bueXA+mDnagj1oTqsWXZ0WnPAYI3WUO7sBf7XUH230wfYXnTSVhujJxiEP/2oWqi2813gtQkKwz9N2p6yT8Vsh3+BaAwwDvtOZMJKUFcabTBSL6NoouzmzwItJ4mIboT6KXaef66rs8jCU=";
            using (var doc = new PDFDoc(input_file))
            {
                ErrorCode error_code = doc.Load(null);

                if (error_code != ErrorCode.e_ErrSuccess)
                {
                    Console.WriteLine("The PDFDoc " + input_file + " Error: " + error_code);
                    return;
                }

                // Do encryption.
                using (var handler = new DRMSecurityHandler())
                {
                    using (var encrypt_data = new DRMEncryptData(true,
                        "Simple-DRM-filter", SecurityHandler.CipherType.e_CipherAES, 16, true, -4))
                    {
                        handler.Initialize(encrypt_data, file_id, initialize_key);
                        doc.SetSecurityHandler(handler);

                        doc.SaveAs(output_file, (int)PDFDoc.SaveFlags.e_SaveFlagNormal);
                    }
                }
            }
            // Do decryption.
            using (var callback = new DRMSecurityEvent(file_id, initialize_key))
            {
                Library.RegisterSecurityCallback("FoxitDRM", callback);
                using (var encrypted_doc = new PDFDoc(output_file))
                {
                    ErrorCode error_code = encrypted_doc.Load(null);
                    if (error_code != ErrorCode.e_ErrSuccess)
                    {
                        Console.WriteLine("The PDFDoc " + output_file + " Error: " + error_code);
                        return;
                    }

                    output_file = output_directory + "foxit_drm_decrypt.pdf";

                    encrypted_doc.RemoveSecurity();
                    encrypted_doc.SaveAs(output_file, (int)PDFDoc.SaveFlags.e_SaveFlagNormal);
                }
            }
        }

        static void CustomSecurity(string input_file)
        {
            string output_file = output_directory + "custom_encrypt.pdf";
            using (var doc = new PDFDoc(input_file))
            {
                using (var callback = new CustomSecurityEvent())
                {
                    ErrorCode error_code = doc.Load(null);

                    if (error_code != ErrorCode.e_ErrSuccess)
                    {
                        Console.WriteLine("The PDFDoc " + input_file + " Error: " + error_code);
                        return;
                    }

                    // Do encryption.
                    using (var handler = new CustomSecurityHandler())
                    {
                        const string encrypt_info = "Foxit simple demo custom security";
                        using (var encrypt_data = new CustomEncryptData(true, "Custom", "foxit-simple-demo"))
                        {
                            handler.Initialize(encrypt_data, callback, encrypt_info);
                            doc.SetSecurityHandler(handler);
                            doc.SaveAs(output_file, (int)PDFDoc.SaveFlags.e_SaveFlagNormal);
                        }
                    }
                    // Do decryption.
                    Library.RegisterSecurityCallback("Custom", callback);
                    using (var encrypted_doc = new PDFDoc(output_file))
                    {
                        error_code = encrypted_doc.Load(null);

                        if (error_code != ErrorCode.e_ErrSuccess)
                        {
                            Console.WriteLine("The PDFDoc " + output_file + " Error: " + error_code);
                            return;
                        }

                        output_file = output_directory + "custom_decrypt.pdf";
                        encrypted_doc.RemoveSecurity();
                        encrypted_doc.SaveAs(output_file, (int)PDFDoc.SaveFlags.e_SaveFlagNormal);
                    }
                }
            }
        }

        static void RmsSecurity(string input_file)
        {
            string output_file = output_directory + "rms_encrypt.pdf";
            using (var callback = new RMSSecurityEvent("Simple-RMS-encrpty-key"))
            {
                using (var doc = new PDFDoc(input_file))
                {
                    ErrorCode error_code = doc.Load(null);

                    if (error_code != ErrorCode.e_ErrSuccess)
                    {
                        Console.WriteLine("The PDFDoc " + input_file + " Error: " + error_code);
                        return;
                    }

                    // Do encryption.
                    using (var handler = new RMSSecurityHandler())
                    {
                        byte[][] server_eul_list = new byte[4][];
                        server_eul_list[0] = Encoding.ASCII.GetBytes("WM-1");
                        server_eul_list[1] = Encoding.ASCII.GetBytes("This document has been encrypted by RMS encryption.");
                        server_eul_list[2] = Encoding.ASCII.GetBytes("WM-2");
                        server_eul_list[3] = Encoding.ASCII.GetBytes("Just for simple demo rms security.");
                        using (var encrypt_data = new RMSEncryptData(true, "PubishLicense_0123", server_eul_list, 1))
                        {
                            handler.Initialize(encrypt_data, callback);
                            doc.SetSecurityHandler(handler);
                            doc.SaveAs(output_file, (int)PDFDoc.SaveFlags.e_SaveFlagNormal);
                        }
                    }
                }
                // Do decryption.
                Library.RegisterSecurityCallback("MicrosoftIRMServices", callback);
                using (var encrypted_doc = new PDFDoc(output_file))
                {
                    ErrorCode error_code = encrypted_doc.Load(null);
                    if (error_code != ErrorCode.e_ErrSuccess)
                    {
                        Console.WriteLine("The PDFDoc " + output_file + " Error: " + error_code);
                        return;
                    }

                    output_file = output_directory + "rms_decrypt.pdf";
                    encrypted_doc.RemoveSecurity();
                    encrypted_doc.SaveAs(output_file, (int)PDFDoc.SaveFlags.e_SaveFlagNormal);
                }
            }
        }

        static void StdSecurity(string input_file)
        {
            string output_file = output_directory + "std_encrypt_userpwd[user]_ownerpwd[owner].pdf";
            using (var doc = new PDFDoc(input_file))
            {
                ErrorCode error_code = doc.Load(null);

                if (error_code != ErrorCode.e_ErrSuccess)
                {
                    Console.WriteLine("The PDFDoc " + input_file + " Error: " + error_code);
                    return;
                }

                // Do encryption.
                using (var handler = new StdSecurityHandler())
                {
                    using (var encrypt_data = new StdEncryptData(true, -4, SecurityHandler.CipherType.e_CipherAES, 16))
                    {
                        handler.Initialize(encrypt_data, Encoding.ASCII.GetBytes("user"), Encoding.ASCII.GetBytes("owner"));
                        doc.SetSecurityHandler(handler);

                        doc.SaveAs(output_file, (int)PDFDoc.SaveFlags.e_SaveFlagNormal);
                    }
                }
            }
            // Do decryption.
            using (var encrypted_doc = new PDFDoc(output_file))
            {
                ErrorCode error_code = encrypted_doc.Load(Encoding.ASCII.GetBytes("owner"));
                if (error_code != ErrorCode.e_ErrSuccess)
                {
                    Console.WriteLine("The PDFDoc " + output_file + " Error: " + error_code);
                    return;
                }

                encrypted_doc.RemoveSecurity();
                output_file = output_directory + "std_decrypt.pdf";
                encrypted_doc.SaveAs(output_file, (int)PDFDoc.SaveFlags.e_SaveFlagNormal);
            }
        }

        static void SecurityImpl(string pdf_file)
        {
            CertificateSecurity(pdf_file);
            FoxitDRMDecrypt(pdf_file);
            CustomSecurity(pdf_file);
            RmsSecurity(pdf_file);
            StdSecurity(pdf_file);
        }
        static void Main(string[] args)
        {
            CreateResultFolder(output_directory);
            // Initialize library
            ErrorCode error_code = Library.Initialize(sn, key);
            if (error_code != ErrorCode.e_ErrSuccess)
            {
                Console.WriteLine("Library Initialize Error: {0}", error_code);
                return;
            }

            try
            {
                string input_file = input_path + "AboutFoxit.pdf";
                SecurityImpl(input_file);

                Console.WriteLine("Security demo test.");
            }
            catch (System.Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Library.Release();
        }
    }
}
