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.

DOCX Encryption Screenshot

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

Upload your file(Drag files here)

Download an input file

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

class Sample
    static void Main(string[] args)
        // If using Professional version, put your serial key below.

        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.

        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