GemBox.Document is a .NET component that enables you to read, write, edit, convert, and print document files from your .NET applications using one simple API.

DOCX Encryption in C# and VB.NET

DOCX encryption enables you to securely protect the content of your Word document (DOCX) from unwanted viewers.

Following example shows how to load encrypted DOCX file and how to save document as encrypted DOCX file.

Input and output password should be specified in the appropriate text box. If password is empty, file won't be decrypted / encrypted.

Screenshot
DOCX Encryption Screenshot

See the full code below, use Run Example to execute.

Upload your file(Drag files here)

Download a sample file

using System;
using GemBox.Document;
using GemBox.Document.Drawing;
using System.IO;
using System.Linq;

class Sample
{
    [STAThread]
    static void Main(string[] args)
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        string inputPassword = "inpass";
        string outputPassword = "outpass";

        var document = DocumentModel.Load("DocxEncryption.docx", new DocxLoadOptions() { Password = inputPassword });

        document.Save("DOCX Encryption.docx", new DocxSaveOptions() { Password = outputPassword });
    }
}
Imports System
Imports GemBox.Document
Imports GemBox.Document.Drawing
Imports System.IO
Imports System.Linq

Module Samples

    Sub Main()

        ' If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY")

        Dim inputPassword As String = "inpass"
        Dim outputPassword As String = "outpass"

        Dim document = DocumentModel.Load("DocxEncryption.docx", New DocxLoadOptions With {.Password = inputPassword})
        document.Save("DOCX Encryption.docx", New DocxSaveOptions With {.Password = outputPassword})

    End Sub

End Module

Check next sample.