Прочетете на английски Редактиране

Споделяне чрез


CryptoProvider.CanDecrypt Property

Definition

Gets a value that indicates whether the user has rights to decrypt.

C#
public bool CanDecrypt { get; }

Property Value

true if the UseLicense grants the user rights to decrypt; otherwise, false.

Examples

The following example shows how to use the CanDecrypt property to determine if decryption is allowed.

C#
ShowStatus("   Binding UseLicense with the SecureEnvironment" +
         "\n       to obtain the CryptoProvider.");
CryptoProvider cryptoProvider = useLicense.Bind(_secureEnv);

ShowStatus("   Obtaining BoundGrants.");
ReadOnlyCollection<ContentGrant> grants =
    cryptoProvider.BoundGrants;

rightsBlockTitle.Text = "Rights - " + Filename(useLicenseFile);
rightsBlock.Text = "GRANTS LIST\n-----------------\n";
foreach (ContentGrant grant in grants)
{
    rightsBlock.Text += "USER:  " + grant.User.Name + " [" +
        grant.User.AuthenticationType + "]\n";
    rightsBlock.Text += "RIGHT: " + grant.Right.ToString() + "\n";
    rightsBlock.Text += "    From:  " + grant.ValidFrom + "\n";
    rightsBlock.Text += "    Until: " + grant.ValidUntil + "\n";
}

if (cryptoProvider.CanDecrypt)
    ShowStatus("   Decryption granted.");
else
    ShowStatus("   CANNOT DECRYPT!");

Remarks

CanDecrypt returns true if the UseLicense bound to this CryptoProvider grants the user read access rights such as View, Edit, Print, or Owner.

Applies to

Продукт Версии
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

See also