CryptoProvider Clase

Definición

Proporciona servicios de administración de derechos digitales para cifrar y descifrar contenido protegido.Provides digital rights management services for encrypting and decrypting protected content.

public ref class CryptoProvider : IDisposable
public class CryptoProvider : IDisposable
[System.Security.SecurityCritical(System.Security.SecurityCriticalScope.Everything)]
public class CryptoProvider : IDisposable
type CryptoProvider = class
    interface IDisposable
[<System.Security.SecurityCritical(System.Security.SecurityCriticalScope.Everything)>]
type CryptoProvider = class
    interface IDisposable
Public Class CryptoProvider
Implements IDisposable
Herencia
CryptoProvider
Atributos
Implementaciones

Ejemplos

En el ejemplo siguiente se muestra cómo utilizar la CryptoProvider clase para crear un EncryptedPackageEnvelope .The following example shows how to use the CryptoProvider class to create an EncryptedPackageEnvelope.

WriteStatus("   Signing the UnsignedPublishLicense\n" +
            "       to build the PublishLicense.");
UseLicense authorsUseLicense;
PublishLicense publishLicense =
    unsignedLicense.Sign(_secureEnv, out authorsUseLicense);

WriteStatus("   Binding the author's UseLicense and");
WriteStatus("       obtaining the CryptoProvider.");
CryptoProvider cryptoProvider = authorsUseLicense.Bind(_secureEnv);

WriteStatus("   Creating the EncryptedPackage.");
Stream packageStream = File.OpenRead(packageFile);
EncryptedPackageEnvelope ePackage =
    EncryptedPackageEnvelope.CreateFromPackage(encryptedFile,
        packageStream, publishLicense, cryptoProvider);

WriteStatus("   Adding an author's UseLicense.");
RightsManagementInformation rmi =
    ePackage.RightsManagementInformation;
rmi.SaveUseLicense(author, authorsUseLicense);

ePackage.Close();
WriteStatus("   Done - Package encryption complete.");

WriteStatus("Verifying package encryption.");
if (EncryptedPackageEnvelope.IsEncryptedPackageEnvelope(encryptedFile))
{
    WriteStatus("   Confirmed - '" + encryptedFilename +
                "' is encrypted.");
}
else
{
    MessageBox.Show("ERROR: '" + encryptedFilename +
        "' is NOT ENCRYPTED.", "Encryption Error",
        MessageBoxButton.OK, MessageBoxImage.Error);
    WriteStatus("ERROR: '" + encryptedFilename +
                "' is NOT ENCRYPTED.\n");
    return false;
}
WriteStatus("   Signing the UnsignedPublishLicense" & vbLf & "       to build the PublishLicense.")
Dim authorsUseLicense As UseLicense = Nothing
Dim publishLicense As PublishLicense = unsignedLicense.Sign(_secureEnv, authorsUseLicense)

WriteStatus("   Binding the author's UseLicense and")
WriteStatus("       obtaining the CryptoProvider.")
Dim cryptoProvider As CryptoProvider = authorsUseLicense.Bind(_secureEnv)

WriteStatus("   Creating the EncryptedPackage.")
Dim packageStream As Stream = File.OpenRead(packageFile)
Dim ePackage As EncryptedPackageEnvelope = EncryptedPackageEnvelope.CreateFromPackage(encryptedFile, packageStream, publishLicense, cryptoProvider)

WriteStatus("   Adding an author's UseLicense.")
Dim rmi As RightsManagementInformation = ePackage.RightsManagementInformation
rmi.SaveUseLicense(author, authorsUseLicense)

ePackage.Close()
WriteStatus("   Done - Package encryption complete.")

WriteStatus("Verifying package encryption.")
If EncryptedPackageEnvelope.IsEncryptedPackageEnvelope(encryptedFile) Then
    WriteStatus("   Confirmed - '" & encryptedFilename & "' is encrypted.")
Else
    MessageBox.Show("ERROR: '" & encryptedFilename & "' is NOT ENCRYPTED.", "Encryption Error", MessageBoxButton.OK, MessageBoxImage.Error)
    WriteStatus("ERROR: '" & encryptedFilename & "' is NOT ENCRYPTED." & vbLf)
    Return False
End If

Comentarios

CryptoProvider se crea como resultado del Bind método al enlazar un derecho administrado UseLicense a SecureEnvironment .CryptoProvider is created as a result of the Bind method when binding a rights managed UseLicense to a SecureEnvironment.

Como con otros System.Security.RightsManagement tipos, CryptoProvider solo se puede usar en aplicaciones de plena confianza.As with other System.Security.RightsManagement types, CryptoProvider is only usable in full trust applications.

Propiedades

BlockSize

Obtiene el tamaño del bloque cifrado, en bytes.Gets the cipher block size, in bytes.

BoundGrants

Obtiene una colección que enumera los derechos que han pasado la comprobación y que se conceden al usuario.Gets a collection listing the rights that passed verification and that are granted to the user.

CanDecrypt

Obtiene un valor que indica si el usuario tiene derechos para descifrar.Gets a value that indicates whether the user has rights to decrypt.

CanEncrypt

Obtiene un valor que indica si el usuario tiene derechos para cifrar.Gets a value that indicates whether the user has rights to encrypt.

CanMergeBlocks

Obtiene un valor que indica si Encrypt(Byte[]) y Decrypt(Byte[]) pueden aceptar búferes con tamaños de bloque de longitud diferente.Gets a value that indicates whether Encrypt(Byte[]) and Decrypt(Byte[]) can accept buffers that are different block sizes in length.

Métodos

Decrypt(Byte[])

Descifra texto cifrado para obtener texto no cifrado.Decrypts cipher text to clear text.

Dispose()

Libera todos los recursos que usa CryptoProvider.Releases all resources used by the CryptoProvider.

Dispose(Boolean)

Libera los recursos no administrados que usa CryptoProvider y, de forma opcional, libera los recursos administrados.Releases the unmanaged resources used by the CryptoProvider and optionally releases the managed resources.

Encrypt(Byte[])

Cifra texto no cifrado para obtener texto cifrado.Encrypts clear text to cipher text.

Equals(Object)

Determina si el objeto especificado es igual que el objeto actual.Determines whether the specified object is equal to the current object.

(Heredado de Object)
Finalize()

Libera recursos y realiza la limpieza interna antes de que recopilación de elementos no utilizados reclame la instancia.Frees resources and performs internal cleanup before the instance is reclaimed by garbage collection.

GetHashCode()

Sirve como la función hash predeterminada.Serves as the default hash function.

(Heredado de Object)
GetType()

Obtiene el Type de la instancia actual.Gets the Type of the current instance.

(Heredado de Object)
MemberwiseClone()

Crea una copia superficial del Object actual.Creates a shallow copy of the current Object.

(Heredado de Object)
ToString()

Devuelve una cadena que representa el objeto actual.Returns a string that represents the current object.

(Heredado de Object)

Se aplica a

Consulte también