Class DocumentProtection
A document's protection settings (w:documentProtection) and write-protection
recommendation (w:writeProtection), as recorded in the settings part.
Modelled, not enforced. DocWright reports what a document asks for and round-trips it unchanged; it does not stop anything. Every editing API in the library will happily modify a document whose Edit is ReadOnly, and rendering ignores these settings entirely. Word applies them as a user-interface convenience, not as a security boundary, and neither does anything else — treat them as a statement of intent.
Password material is preserved, never verified. The hash, salt and algorithm are read and written back byte for byte so a protected document survives a round trip, but nothing in this phase computes or checks them.
public sealed class DocumentProtection : UnknownXmlHost
- Inheritance
-
DocumentProtection
- Inherited Members
Constructors
Properties
- AlgorithmName
Gets or sets the ISO-strengthened algorithm name (w:algorithmName), or null.
- CryptAlgorithmClass
Gets or sets the cryptographic algorithm class (w:cryptAlgorithmClass), or null.
- CryptAlgorithmSid
Gets or sets the cryptographic algorithm identifier (w:cryptAlgorithmSid), or null.
- CryptAlgorithmType
Gets or sets the cryptographic algorithm type (w:cryptAlgorithmType), or null.
- CryptProviderType
Gets or sets the cryptographic provider type (w:cryptProviderType), or null.
- CryptSpinCount
Gets or sets the iteration count used to derive the hash (w:cryptSpinCount), or null.
- Enforcement
Gets or sets whether the restriction is enforced by Word (w:enforcement), or null.
- FormattingRestricted
Gets or sets whether formatting is restricted to the permitted styles (w:formatting), or null.
- HasDocumentProtection
Gets a value indicating whether the document recorded any w:documentProtection content. A document with only a write-protection recommendation reports false.
- HasWriteProtection
Gets a value indicating whether the document recorded a w:writeProtection element.
- Hash
Gets or sets the preserved password hash (w:hash), or null. Never verified.
- HashValue
Gets or sets the ISO-strengthened hash value (w:hashValue), or null. Never verified.
- LegacyPassword
Gets or sets the legacy password hash (w:password), or null. Never verified.
- RawEditToken
Gets or sets the raw w:edit token exactly as the document spelled it, or null. Kept so an unrecognized value round-trips and can be reported rather than guessed at.
- Salt
Gets or sets the preserved salt (w:salt), or null. Never verified.
- SaltValue
Gets or sets the ISO-strengthened salt (w:saltValue), or null.
- SpinCount
Gets or sets the ISO-strengthened iteration count (w:spinCount), or null.
- WriteProtectionHash
Gets or sets the preserved write-protection password hash (w:writeProtection/@w:hash), or null. Never verified.
- WriteProtectionRecommended
Gets or sets whether the document recommends being opened read-only (w:writeProtection/@w:recommended), or null when no w:writeProtection was present.
- WriteProtectionSalt
Gets or sets the preserved write-protection salt (w:writeProtection/@w:salt), or null.
Methods
- Clone()
Creates a deep copy.
- ParseEditRestriction(string?)
Parses a raw w:edit token.
- ToEditToken()
Returns the w:edit token for a restriction, or null when none should be written. An Unrecognized restriction writes back RawEditToken, so a value DocWright did not understand survives.