Table of Contents

Method StartEnforcing

Namespace
DocWright.Cryptography
Assembly
DocWright.Cryptography.dll

StartEnforcing(DocumentProtection, DocumentEditRestriction, string?, IRandomSource?)

Starts enforcing protection as Word's Restrict Editing does (Phase 157, WQ-0130): the restriction with w:enforcement="1" and, for a password, what Word writes for one (the Office 2007 spelling, SHA-512, DefaultSpinCount iterations, a fresh salt). Whatever password material the settings held is replaced or, without a password, removed; a formatting restriction and the write-protection recommendation are left as they are.

public static void StartEnforcing(DocumentProtection protection, DocumentEditRestriction edit, string? password = null, IRandomSource? randomSource = null)

Parameters

protection DocumentProtection

The protection settings to change.

edit DocumentEditRestriction

What editing is restricted to: read only, comments, tracked changes or forms.

password string

The password that stops the protection, or null or empty for none.

randomSource IRandomSource

The salt source, or null for the platform RNG.

Exceptions

ArgumentNullException

protection is null.

ArgumentOutOfRangeException

edit is not one of the four restrictions.