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
protectionDocumentProtectionThe protection settings to change.
editDocumentEditRestrictionWhat editing is restricted to: read only, comments, tracked changes or forms.
passwordstringThe password that stops the protection, or null or empty for none.
randomSourceIRandomSourceThe salt source, or null for the platform RNG.
Exceptions
- ArgumentNullException
protectionis null.- ArgumentOutOfRangeException
editis not one of the four restrictions.