Install Spire.PDF for .NET; then use the below sample C# code to encrypt any PDF files:
static void EncryptPDF()
{
PdfDocument doc = new PdfDocument();
PdfPageBase page = doc.Pages.Add();
DrawPage(page);
doc.Security.KeySize = PdfEncryptionKeySize.Key128Bit;
doc.Security.OwnerPassword = "e-iceblue";
doc.Security.UserPassword = "test";
doc.Security.Permissions = PdfPermissionsFlags.Print | PdfPermissionsFlags.FillFields;
doc.SaveToFile("Encryption.pdf");
doc.Close();
System.Diagnostics.Process.Start("Encryption.pdf");
}