TripleDESCryptoServiceProvider Classe

Definizione

Attenzione

Derived cryptographic types are obsolete. Use the Create method on the base type instead.

Definisce un oggetto wrapper per accedere alla versione CSP (Cryptographic Service Provider, provider del servizio di crittografia) dell'algoritmo TripleDES. La classe non può essere ereditata.

public ref class TripleDESCryptoServiceProvider sealed : System::Security::Cryptography::TripleDES
public sealed class TripleDESCryptoServiceProvider : System.Security.Cryptography.TripleDES
[System.Obsolete("Derived cryptographic types are obsolete. Use the Create method on the base type instead.", DiagnosticId="SYSLIB0021", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public sealed class TripleDESCryptoServiceProvider : System.Security.Cryptography.TripleDES
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class TripleDESCryptoServiceProvider : System.Security.Cryptography.TripleDES
type TripleDESCryptoServiceProvider = class
    inherit TripleDES
[<System.Obsolete("Derived cryptographic types are obsolete. Use the Create method on the base type instead.", DiagnosticId="SYSLIB0021", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
type TripleDESCryptoServiceProvider = class
    inherit TripleDES
[<System.Runtime.InteropServices.ComVisible(true)>]
type TripleDESCryptoServiceProvider = class
    inherit TripleDES
Public NotInheritable Class TripleDESCryptoServiceProvider
Inherits TripleDES
Ereditarietà
TripleDESCryptoServiceProvider
Attributi

Esempio

L'esempio di codice seguente crea un TripleDESCryptoServiceProvider oggetto e lo usa per crittografare e decrittografare i dati in un file.

using namespace System;
using namespace System::Security::Cryptography;
using namespace System::Text;
using namespace System::IO;
void EncryptTextToFile( String^ Data, String^ FileName, array<Byte>^Key, array<Byte>^IV )
{
   try
   {
      
      // Create or open the specified file.
      FileStream^ fStream = File::Open( FileName, FileMode::OpenOrCreate );
      
      // Create a CryptoStream using the FileStream 
      // and the passed key and initialization vector (IV).
      CryptoStream^ cStream = gcnew CryptoStream( fStream,(gcnew TripleDESCryptoServiceProvider)->CreateEncryptor( Key, IV ),CryptoStreamMode::Write );
      
      // Create a StreamWriter using the CryptoStream.
      StreamWriter^ sWriter = gcnew StreamWriter( cStream );
      
      // Write the data to the stream 
      // to encrypt it.
      sWriter->WriteLine( Data );
      
      // Close the streams and
      // close the file.
      sWriter->Close();
      cStream->Close();
      fStream->Close();
   }
   catch ( CryptographicException^ e ) 
   {
      Console::WriteLine( "A Cryptographic error occurred: {0}", e->Message );
   }
   catch ( UnauthorizedAccessException^ e ) 
   {
      Console::WriteLine( "A file access error occurred: {0}", e->Message );
   }

}

String^ DecryptTextFromFile( String^ FileName, array<Byte>^Key, array<Byte>^IV )
{
   try
   {
      
      // Create or open the specified file. 
      FileStream^ fStream = File::Open( FileName, FileMode::OpenOrCreate );
      
      // Create a CryptoStream using the FileStream 
      // and the passed key and initialization vector (IV).
      CryptoStream^ cStream = gcnew CryptoStream( fStream,(gcnew TripleDESCryptoServiceProvider)->CreateDecryptor( Key, IV ),CryptoStreamMode::Read );
      
      // Create a StreamReader using the CryptoStream.
      StreamReader^ sReader = gcnew StreamReader( cStream );
      
      // Read the data from the stream 
      // to decrypt it.
      String^ val = sReader->ReadLine();
      
      // Close the streams and
      // close the file.
      sReader->Close();
      cStream->Close();
      fStream->Close();
      
      // Return the string. 
      return val;
   }
   catch ( CryptographicException^ e ) 
   {
      Console::WriteLine( "A Cryptographic error occurred: {0}", e->Message );
      return nullptr;
   }
   catch ( UnauthorizedAccessException^ e ) 
   {
      Console::WriteLine( "A file access error occurred: {0}", e->Message );
      return nullptr;
   }

}

int main()
{
   try
   {
      
      // Create a new TripleDESCryptoServiceProvider object
      // to generate a key and initialization vector (IV).
      TripleDESCryptoServiceProvider^ tDESalg = gcnew TripleDESCryptoServiceProvider;
      
      // Create a string to encrypt.
      String^ sData = "Here is some data to encrypt.";
      String^ FileName = "CText.txt";
      
      // Encrypt text to a file using the file name, key, and IV.
      EncryptTextToFile( sData, FileName, tDESalg->Key, tDESalg->IV );
      
      // Decrypt the text from a file using the file name, key, and IV.
      String^ Final = DecryptTextFromFile( FileName, tDESalg->Key, tDESalg->IV );
      
      // Display the decrypted string to the console.
      Console::WriteLine( Final );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( e->Message );
   }

}
using System;
using System.Security.Cryptography;
using System.Text;
using System.IO;

class TrippleDESCSPSample
{

    static void Main()
    {
        try
        {
            // Create a new TripleDESCryptoServiceProvider object
            // to generate a key and initialization vector (IV).
            TripleDESCryptoServiceProvider tDESalg = new TripleDESCryptoServiceProvider();

            // Create a string to encrypt.
            string sData = "Here is some data to encrypt.";
            string FileName = "CText.txt";

            // Encrypt text to a file using the file name, key, and IV.
            EncryptTextToFile(sData, FileName, tDESalg.Key, tDESalg.IV);

            // Decrypt the text from a file using the file name, key, and IV.
            string Final = DecryptTextFromFile(FileName, tDESalg.Key, tDESalg.IV);

            // Display the decrypted string to the console.
            Console.WriteLine(Final);
        }
        catch (Exception e)
        {
            Console.WriteLine(e.Message);
        }
    }

    public static void EncryptTextToFile(String Data, String FileName, byte[] Key, byte[] IV)
    {
        try
        {
            // Create or open the specified file.
            FileStream fStream = File.Open(FileName,FileMode.OpenOrCreate);

            // Create a CryptoStream using the FileStream
            // and the passed key and initialization vector (IV).
            CryptoStream cStream = new CryptoStream(fStream,
                new TripleDESCryptoServiceProvider().CreateEncryptor(Key,IV),
                CryptoStreamMode.Write);

            // Create a StreamWriter using the CryptoStream.
            StreamWriter sWriter = new StreamWriter(cStream);

            // Write the data to the stream
            // to encrypt it.
            sWriter.WriteLine(Data);

            // Close the streams and
            // close the file.
            sWriter.Close();
            cStream.Close();
            fStream.Close();
        }
        catch(CryptographicException e)
        {
            Console.WriteLine("A Cryptographic error occurred: {0}", e.Message);
        }
        catch(UnauthorizedAccessException  e)
        {
            Console.WriteLine("A file access error occurred: {0}", e.Message);
        }
    }

    public static string DecryptTextFromFile(String FileName, byte[] Key, byte[] IV)
    {
        try
        {
            // Create or open the specified file.
            FileStream fStream = File.Open(FileName, FileMode.OpenOrCreate);

            // Create a CryptoStream using the FileStream
            // and the passed key and initialization vector (IV).
            CryptoStream cStream = new CryptoStream(fStream,
                new TripleDESCryptoServiceProvider().CreateDecryptor(Key,IV),
                CryptoStreamMode.Read);

            // Create a StreamReader using the CryptoStream.
            StreamReader sReader = new StreamReader(cStream);

            // Read the data from the stream
            // to decrypt it.
            string val = sReader.ReadLine();

            // Close the streams and
            // close the file.
            sReader.Close();
            cStream.Close();
            fStream.Close();

            // Return the string.
            return val;
        }
        catch(CryptographicException e)
        {
            Console.WriteLine("A Cryptographic error occurred: {0}", e.Message);
            return null;
        }
        catch(UnauthorizedAccessException  e)
        {
            Console.WriteLine("A file access error occurred: {0}", e.Message);
            return null;
        }
    }
}
Imports System.Security.Cryptography
Imports System.Text
Imports System.IO

Module TrippleDESCSPSample

    Sub Main()
        Try
            ' Create a new TripleDESCryptoServiceProvider object
            ' to generate a key and initialization vector (IV).
            Dim tDESalg As New TripleDESCryptoServiceProvider

            ' Create a string to encrypt.
            Dim sData As String = "Here is some data to encrypt."
            Dim FileName As String = "CText.txt"

            ' Encrypt text to a file using the file name, key, and IV.
            EncryptTextToFile(sData, FileName, tDESalg.Key, tDESalg.IV)

            ' Decrypt the text from a file using the file name, key, and IV.
            Dim Final As String = DecryptTextFromFile(FileName, tDESalg.Key, tDESalg.IV)

            ' Display the decrypted string to the console.
            Console.WriteLine(Final)
        Catch e As Exception
            Console.WriteLine(e.Message)
        End Try
    End Sub


    Sub EncryptTextToFile(ByVal Data As String, ByVal FileName As String, ByVal Key() As Byte, ByVal IV() As Byte)
        Try
            ' Create or open the specified file.
            Dim fStream As FileStream = File.Open(FileName, FileMode.OpenOrCreate)

            ' Create a CryptoStream using the FileStream 
            ' and the passed key and initialization vector (IV).
            Dim cStream As New CryptoStream(fStream, _
                                            New TripleDESCryptoServiceProvider().CreateEncryptor(Key, IV), _
                                            CryptoStreamMode.Write)

            ' Create a StreamWriter using the CryptoStream.
            Dim sWriter As New StreamWriter(cStream)

            ' Write the data to the stream 
            ' to encrypt it.
            sWriter.WriteLine(Data)

            ' Close the streams and
            ' close the file.
            sWriter.Close()
            cStream.Close()
            fStream.Close()
        Catch e As CryptographicException
            Console.WriteLine("A Cryptographic error occurred: {0}", e.Message)
        Catch e As UnauthorizedAccessException
            Console.WriteLine("A file error occurred: {0}", e.Message)
        End Try
    End Sub


    Function DecryptTextFromFile(ByVal FileName As String, ByVal Key() As Byte, ByVal IV() As Byte) As String
        Try
            ' Create or open the specified file. 
            Dim fStream As FileStream = File.Open(FileName, FileMode.OpenOrCreate)

            ' Create a CryptoStream using the FileStream 
            ' and the passed key and initialization vector (IV).
            Dim cStream As New CryptoStream(fStream, _
                                            New TripleDESCryptoServiceProvider().CreateDecryptor(Key, IV), _
                                            CryptoStreamMode.Read)

            ' Create a StreamReader using the CryptoStream.
            Dim sReader As New StreamReader(cStream)

            ' Read the data from the stream 
            ' to decrypt it.
            Dim val As String = sReader.ReadLine()

            ' Close the streams and
            ' close the file.
            sReader.Close()
            cStream.Close()
            fStream.Close()

            ' Return the string. 
            Return val
        Catch e As CryptographicException
            Console.WriteLine("A Cryptographic error occurred: {0}", e.Message)
            Return Nothing
        Catch e As UnauthorizedAccessException
            Console.WriteLine("A file error occurred: {0}", e.Message)
            Return Nothing
        End Try
    End Function
End Module

L'esempio di codice seguente crea un TripleDESCryptoServiceProvider oggetto e lo usa per crittografare e decrittografare i dati in memoria.

using namespace System;
using namespace System::Security::Cryptography;
using namespace System::Text;
using namespace System::IO;
array<Byte>^ EncryptTextToMemory( String^ Data, array<Byte>^Key, array<Byte>^IV )
{
   try
   {
      
      // Create a MemoryStream.
      MemoryStream^ mStream = gcnew MemoryStream;
      
      // Create a CryptoStream using the MemoryStream 
      // and the passed key and initialization vector (IV).
      CryptoStream^ cStream = gcnew CryptoStream( mStream,(gcnew TripleDESCryptoServiceProvider)->CreateEncryptor( Key, IV ),CryptoStreamMode::Write );
      
      // Convert the passed string to a byte array.
      array<Byte>^toEncrypt = (gcnew ASCIIEncoding)->GetBytes( Data );
      
      // Write the byte array to the crypto stream and flush it.
      cStream->Write( toEncrypt, 0, toEncrypt->Length );
      cStream->FlushFinalBlock();
      
      // Get an array of bytes from the 
      // MemoryStream that holds the 
      // encrypted data.
      array<Byte>^ret = mStream->ToArray();
      
      // Close the streams.
      cStream->Close();
      mStream->Close();
      
      // Return the encrypted buffer.
      return ret;
   }
   catch ( CryptographicException^ e ) 
   {
      Console::WriteLine( "A Cryptographic error occurred: {0}", e->Message );
      return nullptr;
   }

}

String^ DecryptTextFromMemory( array<Byte>^Data, array<Byte>^Key, array<Byte>^IV )
{
   try
   {
      
      // Create a new MemoryStream using the passed 
      // array of encrypted data.
      MemoryStream^ msDecrypt = gcnew MemoryStream( Data );
      
      // Create a CryptoStream using the MemoryStream 
      // and the passed key and initialization vector (IV).
      CryptoStream^ csDecrypt = gcnew CryptoStream( msDecrypt,(gcnew TripleDESCryptoServiceProvider)->CreateDecryptor( Key, IV ),CryptoStreamMode::Read );
      
      // Create buffer to hold the decrypted data.
      array<Byte>^fromEncrypt = gcnew array<Byte>(Data->Length);
      
      // Read the decrypted data out of the crypto stream
      // and place it into the temporary buffer.
      csDecrypt->Read( fromEncrypt, 0, fromEncrypt->Length );
      
      //Convert the buffer into a string and return it.
      return (gcnew ASCIIEncoding)->GetString( fromEncrypt );
   }
   catch ( CryptographicException^ e ) 
   {
      Console::WriteLine( "A Cryptographic error occurred: {0}", e->Message );
      return nullptr;
   }

}

int main()
{
   try
   {
      
      // Create a new TripleDESCryptoServiceProvider object
      // to generate a key and initialization vector (IV).
      TripleDESCryptoServiceProvider^ tDESalg = gcnew TripleDESCryptoServiceProvider;
      
      // Create a string to encrypt.
      String^ sData = "Here is some data to encrypt.";
      
      // Encrypt the string to an in-memory buffer.
      array<Byte>^Data = EncryptTextToMemory( sData, tDESalg->Key, tDESalg->IV );
      
      // Decrypt the buffer back to a string.
      String^ Final = DecryptTextFromMemory( Data, tDESalg->Key, tDESalg->IV );
      
      // Display the decrypted string to the console.
      Console::WriteLine( Final );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( e->Message );
   }

}
using System;
using System.Security.Cryptography;
using System.Text;
using System.IO;

class TrippleDESCSPSample
{

    static void Main()
    {
        try
        {
            // Create a new TripleDESCryptoServiceProvider object
            // to generate a key and initialization vector (IV).
            TripleDESCryptoServiceProvider tDESalg = new TripleDESCryptoServiceProvider();

            // Create a string to encrypt.
            string sData = "Here is some data to encrypt.";

            // Encrypt the string to an in-memory buffer.
            byte[] Data = EncryptTextToMemory(sData, tDESalg.Key, tDESalg.IV);

            // Decrypt the buffer back to a string.
            string Final = DecryptTextFromMemory(Data, tDESalg.Key, tDESalg.IV);

            // Display the decrypted string to the console.
            Console.WriteLine(Final);
        }
        catch (Exception e)
        {
            Console.WriteLine(e.Message);
        }
    }

    public static byte[] EncryptTextToMemory(string Data,  byte[] Key, byte[] IV)
    {
        try
        {
            // Create a MemoryStream.
            MemoryStream mStream = new MemoryStream();

            // Create a CryptoStream using the MemoryStream
            // and the passed key and initialization vector (IV).
            CryptoStream cStream = new CryptoStream(mStream,
                new TripleDESCryptoServiceProvider().CreateEncryptor(Key, IV),
                CryptoStreamMode.Write);

            // Convert the passed string to a byte array.
            byte[] toEncrypt = new ASCIIEncoding().GetBytes(Data);

            // Write the byte array to the crypto stream and flush it.
            cStream.Write(toEncrypt, 0, toEncrypt.Length);
            cStream.FlushFinalBlock();

            // Get an array of bytes from the
            // MemoryStream that holds the
            // encrypted data.
            byte[] ret = mStream.ToArray();

            // Close the streams.
            cStream.Close();
            mStream.Close();

            // Return the encrypted buffer.
            return ret;
        }
        catch(CryptographicException e)
        {
            Console.WriteLine("A Cryptographic error occurred: {0}", e.Message);
            return null;
        }
    }

    public static string DecryptTextFromMemory(byte[] Data,  byte[] Key, byte[] IV)
    {
        try
        {
            // Create a new MemoryStream using the passed
            // array of encrypted data.
            MemoryStream msDecrypt = new MemoryStream(Data);

            // Create a CryptoStream using the MemoryStream
            // and the passed key and initialization vector (IV).
            CryptoStream csDecrypt = new CryptoStream(msDecrypt,
                new TripleDESCryptoServiceProvider().CreateDecryptor(Key, IV),
                CryptoStreamMode.Read);

            // Create buffer to hold the decrypted data.
            byte[] fromEncrypt = new byte[Data.Length];

            // Read the decrypted data out of the crypto stream
            // and place it into the temporary buffer.
            csDecrypt.Read(fromEncrypt, 0, fromEncrypt.Length);

            //Convert the buffer into a string and return it.
            return new ASCIIEncoding().GetString(fromEncrypt);
        }
        catch(CryptographicException e)
        {
            Console.WriteLine("A Cryptographic error occurred: {0}", e.Message);
            return null;
        }
    }
}
Imports System.Security.Cryptography
Imports System.Text
Imports System.IO

Module TrippleDESCSPSample

    Sub Main()
        Try
            ' Create a new TripleDESCryptoServiceProvider object
            ' to generate a key and initialization vector (IV).
            Dim tDESalg As New TripleDESCryptoServiceProvider

            ' Create a string to encrypt.
            Dim sData As String = "Here is some data to encrypt."

            ' Encrypt the string to an in-memory buffer.
            Dim Data As Byte() = EncryptTextToMemory(sData, tDESalg.Key, tDESalg.IV)

            ' Decrypt the buffer back to a string.
            Dim Final As String = DecryptTextFromMemory(Data, tDESalg.Key, tDESalg.IV)

            ' Display the decrypted string to the console.
            Console.WriteLine(Final)
        Catch e As Exception
            Console.WriteLine(e.Message)
        End Try
    End Sub


    Function EncryptTextToMemory(ByVal Data As String, ByVal Key() As Byte, ByVal IV() As Byte) As Byte()
        Try
            ' Create a MemoryStream.
            Dim mStream As New MemoryStream

            ' Create a CryptoStream using the MemoryStream 
            ' and the passed key and initialization vector (IV).
            Dim cStream As New CryptoStream(mStream, _
                                            New TripleDESCryptoServiceProvider().CreateEncryptor(Key, IV), _
                                            CryptoStreamMode.Write)

            ' Convert the passed string to a byte array.
            Dim toEncrypt As Byte() = New ASCIIEncoding().GetBytes(Data)

            ' Write the byte array to the crypto stream and flush it.
            cStream.Write(toEncrypt, 0, toEncrypt.Length)
            cStream.FlushFinalBlock()

            ' Get an array of bytes from the 
            ' MemoryStream that holds the 
            ' encrypted data.
            Dim ret As Byte() = mStream.ToArray()

            ' Close the streams.
            cStream.Close()
            mStream.Close()

            ' Return the encrypted buffer.
            Return ret
        Catch e As CryptographicException
            Console.WriteLine("A Cryptographic error occurred: {0}", e.Message)
            Return Nothing
        End Try
    End Function


    Function DecryptTextFromMemory(ByVal Data() As Byte, ByVal Key() As Byte, ByVal IV() As Byte) As String
        Try
            ' Create a new MemoryStream using the passed 
            ' array of encrypted data.
            Dim msDecrypt As New MemoryStream(Data)

            ' Create a CryptoStream using the MemoryStream 
            ' and the passed key and initialization vector (IV).
            Dim csDecrypt As New CryptoStream(msDecrypt, _
                                              New TripleDESCryptoServiceProvider().CreateDecryptor(Key, IV), _
                                              CryptoStreamMode.Read)

            ' Create buffer to hold the decrypted data.
            Dim fromEncrypt(Data.Length - 1) As Byte

            ' Read the decrypted data out of the crypto stream
            ' and place it into the temporary buffer.
            csDecrypt.Read(fromEncrypt, 0, fromEncrypt.Length)

            'Convert the buffer into a string and return it.
            Return New ASCIIEncoding().GetString(fromEncrypt)
        Catch e As CryptographicException
            Console.WriteLine("A Cryptographic error occurred: {0}", e.Message)
            Return Nothing
        End Try
    End Function
End Module

Commenti

Questo algoritmo supporta lunghezze di chiave da 128 bit a 192 bit in incrementi di 64 bit.

Nota

È disponibile un algoritmo di crittografia simmetrica più recente, Advanced Encryption Standard (AES). Prendere in considerazione l'uso della AesCryptoServiceProvider classe anziché della TripleDESCryptoServiceProvider classe . Usare TripleDESCryptoServiceProvider solo per la compatibilità con applicazioni e dati legacy.

Costruttori

TripleDESCryptoServiceProvider()

Inizializza una nuova istanza della classe TripleDESCryptoServiceProvider.

Campi

BlockSizeValue

Rappresenta la dimensione in bit del blocco dell'operazione di crittografia.

(Ereditato da SymmetricAlgorithm)
FeedbackSizeValue

Rappresenta la dimensione in bit della quantità di informazioni raccolte dell'operazione di crittografia.

(Ereditato da SymmetricAlgorithm)
IVValue

Rappresenta il vettore di inizializzazione IV per l'algoritmo simmetrico.

(Ereditato da SymmetricAlgorithm)
KeySizeValue

Rappresenta la dimensione in bit della chiave privata usata dall'algoritmo simmetrico.

(Ereditato da SymmetricAlgorithm)
KeyValue

Rappresenta la chiave privata per l'algoritmo simmetrico.

(Ereditato da SymmetricAlgorithm)
LegalBlockSizesValue

Specifica le dimensioni in bit dei blocchi supportate dall'algoritmo simmetrico.

(Ereditato da SymmetricAlgorithm)
LegalKeySizesValue

Specifica le dimensioni in bit delle chiavi supportate dall'algoritmo simmetrico.

(Ereditato da SymmetricAlgorithm)
ModeValue

Rappresenta la modalità di crittografia usata nell'algoritmo simmetrico.

(Ereditato da SymmetricAlgorithm)
PaddingValue

Rappresenta la modalità di riempimento usata nell'algoritmo simmetrico.

(Ereditato da SymmetricAlgorithm)

Proprietà

BlockSize

Ottiene o imposta la dimensione in bit del blocco dell'operazione di crittografia.

BlockSize

Ottiene o imposta la dimensione in bit del blocco dell'operazione di crittografia.

(Ereditato da SymmetricAlgorithm)
FeedbackSize

Ottiene o imposta le dimensioni delle informazioni raccolte dell'operazione di crittografia per le modalità di crittografia CFB (Cipher Feedback) e OFB (Output Feedback).

FeedbackSize

Ottiene o imposta le dimensioni delle informazioni raccolte dell'operazione di crittografia per le modalità di crittografia CFB (Cipher Feedback) e OFB (Output Feedback).

(Ereditato da SymmetricAlgorithm)
IV

Ottiene o imposta il vettore di inizializzazione (IV) per l'algoritmo simmetrico.

IV

Ottiene o imposta il vettore di inizializzazione (IV) per l'algoritmo simmetrico.

(Ereditato da SymmetricAlgorithm)
Key

Ottiene o imposta la chiave privata per l'algoritmo TripleDES.

Key

Ottiene o imposta la chiave privata per l'algoritmo TripleDES.

(Ereditato da TripleDES)
KeySize

Ottiene o imposta la dimensione della chiave privata, in bit.

KeySize

Ottiene o imposta la dimensione in bit della chiave segreta utilizzata dall'algoritmo simmetrico.

(Ereditato da SymmetricAlgorithm)
LegalBlockSizes

Ottiene le dimensioni in bit dei blocchi supportate dall'algoritmo simmetrico.

LegalBlockSizes

Ottiene le dimensioni in bit dei blocchi supportate dall'algoritmo simmetrico.

(Ereditato da TripleDES)
LegalKeySizes

Ottiene le dimensioni in bit delle chiavi supportate dall'algoritmo simmetrico.

LegalKeySizes

Ottiene le dimensioni in bit delle chiavi supportate dall'algoritmo simmetrico.

(Ereditato da TripleDES)
Mode

Ottiene o imposta la modalità di funzionamento dell'algoritmo simmetrico.

Mode

Ottiene o imposta la modalità di funzionamento dell'algoritmo simmetrico.

(Ereditato da SymmetricAlgorithm)
Padding

Ottiene o imposta la modalità di riempimento usata nell'algoritmo simmetrico.

Padding

Ottiene o imposta la modalità di riempimento usata nell'algoritmo simmetrico.

(Ereditato da SymmetricAlgorithm)

Metodi

Clear()

Rilascia tutte le risorse usate dalla classe SymmetricAlgorithm.

(Ereditato da SymmetricAlgorithm)
CreateDecryptor()

Crea un oggetto di decrittografia simmetrica con la proprietà Key corrente e il vettore di inizializzazione IV.

CreateDecryptor()

Crea un oggetto di decrittografia simmetrica con la proprietà Key corrente e il vettore di inizializzazione IV.

(Ereditato da SymmetricAlgorithm)
CreateDecryptor(Byte[], Byte[])

Crea un oggetto di decrittografia TripleDES simmetrica con la chiave Key e il vettore di inizializzazione IV specificati.

CreateEncryptor()

Crea un oggetto di crittografia simmetrica con la proprietà Key corrente e il vettore di inizializzazione IV.

CreateEncryptor()

Crea un oggetto di crittografia simmetrica con la proprietà Key corrente e il vettore di inizializzazione IV.

(Ereditato da SymmetricAlgorithm)
CreateEncryptor(Byte[], Byte[])

Crea un oggetto di crittografia TripleDES simmetrica con la chiave Key e il vettore di inizializzazione IV specificati.

DecryptCbc(Byte[], Byte[], PaddingMode)

Decrittografa i dati usando la modalità CBC con la modalità di riempimento specificata.

(Ereditato da SymmetricAlgorithm)
DecryptCbc(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, PaddingMode)

Decrittografa i dati usando la modalità CBC con la modalità di riempimento specificata.

(Ereditato da SymmetricAlgorithm)
DecryptCbc(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Span<Byte>, PaddingMode)

Decrittografa i dati nel buffer specificato, usando la modalità CBC con la modalità di riempimento specificata.

(Ereditato da SymmetricAlgorithm)
DecryptCfb(Byte[], Byte[], PaddingMode, Int32)

Decrittografa i dati usando la modalità CFB con la modalità di riempimento e le dimensioni del feedback specificate.

(Ereditato da SymmetricAlgorithm)
DecryptCfb(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, PaddingMode, Int32)

Decrittografa i dati usando la modalità CFB con la modalità di riempimento e le dimensioni del feedback specificate.

(Ereditato da SymmetricAlgorithm)
DecryptCfb(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Span<Byte>, PaddingMode, Int32)

Decrittografa i dati nel buffer specificato, usando la modalità CFB con la modalità di riempimento e le dimensioni del feedback specificate.

(Ereditato da SymmetricAlgorithm)
DecryptEcb(Byte[], PaddingMode)

Decrittografa i dati usando la modalità STANDBY con la modalità di riempimento specificata.

(Ereditato da SymmetricAlgorithm)
DecryptEcb(ReadOnlySpan<Byte>, PaddingMode)

Decrittografa i dati usando la modalità STANDBY con la modalità di riempimento specificata.

(Ereditato da SymmetricAlgorithm)
DecryptEcb(ReadOnlySpan<Byte>, Span<Byte>, PaddingMode)

Decrittografa i dati nel buffer specificato, utilizzando la modalità DISA con la modalità di riempimento specificata.

(Ereditato da SymmetricAlgorithm)
Dispose()

Rilascia tutte le risorse usate dall'istanza corrente della classe SymmetricAlgorithm.

(Ereditato da SymmetricAlgorithm)
Dispose(Boolean)

Rilascia le risorse non gestite usate da SymmetricAlgorithm e, facoltativamente, le risorse gestite.

(Ereditato da SymmetricAlgorithm)
EncryptCbc(Byte[], Byte[], PaddingMode)

Crittografa i dati usando la modalità CBC con la modalità di riempimento specificata.

(Ereditato da SymmetricAlgorithm)
EncryptCbc(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, PaddingMode)

Crittografa i dati usando la modalità CBC con la modalità di riempimento specificata.

(Ereditato da SymmetricAlgorithm)
EncryptCbc(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Span<Byte>, PaddingMode)

Crittografa i dati nel buffer specificato, usando la modalità CBC con la modalità di riempimento specificata.

(Ereditato da SymmetricAlgorithm)
EncryptCfb(Byte[], Byte[], PaddingMode, Int32)

Crittografa i dati usando la modalità CFB con la modalità di riempimento e le dimensioni del feedback specificate.

(Ereditato da SymmetricAlgorithm)
EncryptCfb(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, PaddingMode, Int32)

Crittografa i dati usando la modalità CFB con la modalità di riempimento e le dimensioni del feedback specificate.

(Ereditato da SymmetricAlgorithm)
EncryptCfb(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Span<Byte>, PaddingMode, Int32)

Crittografa i dati nel buffer specificato, usando la modalità CFB con la modalità di riempimento e le dimensioni del feedback specificate.

(Ereditato da SymmetricAlgorithm)
EncryptEcb(Byte[], PaddingMode)

Crittografa i dati usando la modalità DISA con la modalità di riempimento specificata.

(Ereditato da SymmetricAlgorithm)
EncryptEcb(ReadOnlySpan<Byte>, PaddingMode)

Crittografa i dati usando la modalità DISA con la modalità di riempimento specificata.

(Ereditato da SymmetricAlgorithm)
EncryptEcb(ReadOnlySpan<Byte>, Span<Byte>, PaddingMode)

Crittografa i dati nel buffer specificato, usando la modalità BCE con la modalità di riempimento specificata.

(Ereditato da SymmetricAlgorithm)
Equals(Object)

Determina se l'oggetto specificato è uguale all'oggetto corrente.

(Ereditato da Object)
GenerateIV()

Genera un vettore di inizializzazione casuale IV da utilizzare per l'algoritmo.

GenerateKey()

Consente di generare una proprietà Key casuale da utilizzare per l'algoritmo.

GetCiphertextLengthCbc(Int32, PaddingMode)

Ottiene la lunghezza di un testo crittografato con una modalità di riempimento e una lunghezza di testo non crittografato specificati in modalità CBC.

(Ereditato da SymmetricAlgorithm)
GetCiphertextLengthCfb(Int32, PaddingMode, Int32)

Ottiene la lunghezza di un testo crittografato con una modalità di riempimento e una lunghezza di testo non crittografato specificati in modalità CFB.

(Ereditato da SymmetricAlgorithm)
GetCiphertextLengthEcb(Int32, PaddingMode)

Ottiene la lunghezza di un testo crittografato con una modalità di riempimento e una lunghezza di testo non crittografato specificati in modalità BCE.

(Ereditato da SymmetricAlgorithm)
GetHashCode()

Funge da funzione hash predefinita.

(Ereditato da Object)
GetType()

Ottiene l'oggetto Type dell'istanza corrente.

(Ereditato da Object)
MemberwiseClone()

Crea una copia superficiale dell'oggetto Object corrente.

(Ereditato da Object)
ToString()

Restituisce una stringa che rappresenta l'oggetto corrente.

(Ereditato da Object)
TryDecryptCbc(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Span<Byte>, Int32, PaddingMode)

Tenta di decrittografare i dati nel buffer specificato, usando la modalità CBC con la modalità di riempimento specificata.

(Ereditato da SymmetricAlgorithm)
TryDecryptCbcCore(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Span<Byte>, PaddingMode, Int32)

Quando sottoposto a override in una classe derivata, tenta di decrittografare i dati nel buffer specificato, usando la modalità CBC con la modalità di riempimento specificata.

(Ereditato da SymmetricAlgorithm)
TryDecryptCfb(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Span<Byte>, Int32, PaddingMode, Int32)

Tenta di decrittografare i dati nel buffer specificato, usando la modalità CFB con la modalità di riempimento e le dimensioni del feedback specificate.

(Ereditato da SymmetricAlgorithm)
TryDecryptCfbCore(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Span<Byte>, PaddingMode, Int32, Int32)

Quando sottoposto a override in una classe derivata, tenta di decrittografare i dati nel buffer specificato, usando la modalità CFB con la modalità di riempimento e le dimensioni di feedback specificate.

(Ereditato da SymmetricAlgorithm)
TryDecryptEcb(ReadOnlySpan<Byte>, Span<Byte>, PaddingMode, Int32)

Tenta di decrittografare i dati nel buffer specificato, usando la modalità BCE con la modalità di riempimento specificata.

(Ereditato da SymmetricAlgorithm)
TryDecryptEcbCore(ReadOnlySpan<Byte>, Span<Byte>, PaddingMode, Int32)

Quando sottoposto a override in una classe derivata, tenta di decrittografare i dati nel buffer specificato, usando la modalità ECB con la modalità di riempimento specificata.

(Ereditato da SymmetricAlgorithm)
TryEncryptCbc(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Span<Byte>, Int32, PaddingMode)

Tenta di crittografare i dati nel buffer specificato, usando la modalità CBC con la modalità di riempimento specificata.

(Ereditato da SymmetricAlgorithm)
TryEncryptCbcCore(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Span<Byte>, PaddingMode, Int32)

Quando sottoposto a override in una classe derivata, tenta di crittografare i dati nel buffer specificato, usando la modalità CBC con la modalità di riempimento specificata.

(Ereditato da SymmetricAlgorithm)
TryEncryptCfb(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Span<Byte>, Int32, PaddingMode, Int32)

Tenta di crittografare i dati nel buffer specificato, usando la modalità CFB con la modalità di riempimento e le dimensioni del feedback specificate.

(Ereditato da SymmetricAlgorithm)
TryEncryptCfbCore(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Span<Byte>, PaddingMode, Int32, Int32)

Quando sottoposto a override in una classe derivata, tenta di crittografare i dati nel buffer specificato, usando la modalità CFB con la modalità di riempimento e le dimensioni di feedback specificate.

(Ereditato da SymmetricAlgorithm)
TryEncryptEcb(ReadOnlySpan<Byte>, Span<Byte>, PaddingMode, Int32)

Tenta di crittografare i dati nel buffer specificato, usando la modalità BCE con la modalità di riempimento specificata.

(Ereditato da SymmetricAlgorithm)
TryEncryptEcbCore(ReadOnlySpan<Byte>, Span<Byte>, PaddingMode, Int32)

Quando sottoposto a override in una classe derivata, tenta di crittografare i dati nel buffer specificato, usando la modalità ECB con la modalità di riempimento specificata.

(Ereditato da SymmetricAlgorithm)
ValidKeySize(Int32)

Determina se la dimensione specificata della chiave è valida per l'algoritmo corrente.

(Ereditato da SymmetricAlgorithm)

Implementazioni dell'interfaccia esplicita

IDisposable.Dispose()

Questa API supporta l'infrastruttura del prodotto e non è previsto che venga usata direttamente dal codice.

Rilascia le risorse non gestite usate da SymmetricAlgorithm e, facoltativamente, le risorse gestite.

(Ereditato da SymmetricAlgorithm)

Si applica a

Vedi anche