TripleDES 類別

定義

代表三重資料加密標準演算法的基底類別,所有 TripleDES 實作都必須從此衍生出來。

public ref class TripleDES abstract : System::Security::Cryptography::SymmetricAlgorithm
public abstract class TripleDES : System.Security.Cryptography.SymmetricAlgorithm
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public abstract class TripleDES : System.Security.Cryptography.SymmetricAlgorithm
[System.Runtime.InteropServices.ComVisible(true)]
public abstract class TripleDES : System.Security.Cryptography.SymmetricAlgorithm
type TripleDES = class
    inherit SymmetricAlgorithm
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
type TripleDES = class
    inherit SymmetricAlgorithm
[<System.Runtime.InteropServices.ComVisible(true)>]
type TripleDES = class
    inherit SymmetricAlgorithm
Public MustInherit Class TripleDES
Inherits SymmetricAlgorithm
繼承
衍生
屬性

範例

以下程式碼範例展示了如何建立並使用 TripleDES 物件來加密和解密檔案中的資料。

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

class TripleDESSample
{
    static void Main()
    {
        try
        {
            byte[] key;
            byte[] iv;

            // Create a new TripleDES object to generate a random key
            // and initialization vector (IV).
            using (TripleDES tripleDes = TripleDES.Create())
            {
                key = tripleDes.Key;
                iv = tripleDes.IV;
            }

            // Create a string to encrypt.
            string original = "Here is some data to encrypt.";
            // The name/path of the file to write.
            string filename = "CText.enc";

            // Encrypt the string to a file.
            EncryptTextToFile(original, filename, key, iv);

            // Decrypt the file back to a string.
            string decrypted = DecryptTextFromFile(filename, key, iv);

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

    public static void EncryptTextToFile(string text, string path, byte[] key, byte[] iv)
    {
        try
        {
            // Create or open the specified file.
            using (FileStream fStream = File.Open(path, FileMode.Create))
            // Create a new TripleDES object.
            using (TripleDES tripleDes = TripleDES.Create())
            // Create a TripleDES encryptor from the key and IV
            using (ICryptoTransform encryptor = tripleDes.CreateEncryptor(key, iv))
            // Create a CryptoStream using the FileStream and encryptor
            using (var cStream = new CryptoStream(fStream, encryptor, CryptoStreamMode.Write))
            {
                // Convert the provided string to a byte array.
                byte[] toEncrypt = Encoding.UTF8.GetBytes(text);

                // Write the byte array to the crypto stream.
                cStream.Write(toEncrypt, 0, toEncrypt.Length);
            }
        }
        catch (CryptographicException e)
        {
            Console.WriteLine("A Cryptographic error occurred: {0}", e.Message);
            throw;
        }
    }

    public static string DecryptTextFromFile(string path, byte[] key, byte[] iv)
    {
        try
        {
            // Open the specified file
            using (FileStream fStream = File.OpenRead(path))
            // Create a new TripleDES object.
            using (TripleDES tripleDes = TripleDES.Create())
            // Create a TripleDES decryptor from the key and IV
            using (ICryptoTransform decryptor = tripleDes.CreateDecryptor(key, iv))
            // Create a CryptoStream using the FileStream and decryptor
            using (var cStream = new CryptoStream(fStream, decryptor, CryptoStreamMode.Read))
            // Create a StreamReader to turn the bytes back into text
            using (StreamReader reader = new StreamReader(cStream, Encoding.UTF8))
            {
                // Read back all of the text from the StreamReader, which receives
                // the decrypted bytes from the CryptoStream, which receives the
                // encrypted bytes from the FileStream.
                return reader.ReadToEnd();
            }
        }
        catch (CryptographicException e)
        {
            Console.WriteLine("A Cryptographic error occurred: {0}", e.Message);
            throw;
        }
    }
}
Imports System.IO
Imports System.Security.Cryptography
Imports System.Text

Module TripleDESSample

    Sub Main()
        Try
            Dim key As Byte()
            Dim iv As Byte()

            ' Create a new TripleDES object to generate a key
            ' and initialization vector (IV).
            Using tripleDes As TripleDES = TripleDES.Create
                key = tripleDes.Key
                iv = tripleDes.IV
            End Using

            ' Create a string to encrypt.
            Dim original As String = "Here is some data to encrypt."
            ' The name/path of the file to write.
            Dim filename As String = "CText.enc"

            ' Encrypt the string to a file.
            EncryptTextToFile(original, filename, key, iv)

            ' Decrypt the file back to a string.
            Dim decrypted As String = DecryptTextFromFile(filename, key, iv)

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


    Sub EncryptTextToFile(text As String, path As String, key As Byte(), iv As Byte())
        Try
            ' Create or open the specified file.
            ' Create a new TripleDES object,
            ' Create a TripleDES encryptor from the key and IV,
            ' Create a CryptoStream using the MemoryStream And encryptor
            Using fStream As FileStream = File.Open(path, FileMode.Create),
                tripleDes As TripleDES = TripleDES.Create,
                encryptor As ICryptoTransform = tripleDes.CreateEncryptor(key, iv),
                cStream = New CryptoStream(fStream, encryptor, CryptoStreamMode.Write)

                ' Convert the passed string to a byte array.
                Dim toEncrypt As Byte() = Encoding.UTF8.GetBytes(text)

                ' Write the byte array to the crypto stream.
                cStream.Write(toEncrypt, 0, toEncrypt.Length)
            End Using

        Catch e As CryptographicException
            Console.WriteLine("A Cryptographic error occurred: {0}", e.Message)
            Throw
        End Try
    End Sub


    Function DecryptTextFromFile(path As String, key As Byte(), iv As Byte()) As String
        Try
            ' Open the specified file
            ' Create a new TripleDES object.
            ' Create a TripleDES decryptor from the key and IV
            ' Create a CryptoStream using the MemoryStream and decryptor
            ' Create a StreamReader to turn the bytes back into text
            Using mStream As FileStream = File.OpenRead(path),
                tripleDes As TripleDES = TripleDES.Create,
                decryptor As ICryptoTransform = tripleDes.CreateDecryptor(key, iv),
                cStream = New CryptoStream(mStream, decryptor, CryptoStreamMode.Read),
                reader = New StreamReader(cStream, Encoding.UTF8)

                ' Read back all of the text from the StreamReader, which receives
                ' the decrypted bytes from the CryptoStream, which receives the
                ' encrypted bytes from the FileStream.
                Return reader.ReadToEnd()
            End Using
        Catch e As CryptographicException
            Console.WriteLine("A Cryptographic error occurred: {0}", e.Message)
            Return Nothing
        End Try
    End Function
End Module

以下程式碼範例展示如何建立並使用 TripleDES 物件來加密與解密記憶體中的資料。

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

class TripleDESSample2
{
    static void Main()
    {
        try
        {
            byte[] key;
            byte[] iv;

            // Create a new TripleDES object to generate a random key
            // and initialization vector (IV).
            using (TripleDES tripleDes = TripleDES.Create())
            {
                key = tripleDes.Key;
                iv = tripleDes.IV;
            }

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

            // Encrypt the string to an in-memory buffer.
            byte[] encrypted = EncryptTextToMemory(original, key, iv);

            // Decrypt the buffer back to a string.
            string decrypted = DecryptTextFromMemory(encrypted, key, iv);

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

    public static byte[] EncryptTextToMemory(string text, byte[] key, byte[] iv)
    {
        try
        {
            // Create a MemoryStream.
            using (MemoryStream mStream = new MemoryStream())
            {
                // Create a new TripleDES object.
                using (TripleDES tripleDes = TripleDES.Create())
                // Create a TripleDES encryptor from the key and IV
                using (ICryptoTransform encryptor = tripleDes.CreateEncryptor(key, iv))
                // Create a CryptoStream using the MemoryStream and encryptor
                using (var cStream = new CryptoStream(mStream, encryptor, CryptoStreamMode.Write))
                {
                    // Convert the provided string to a byte array.
                    byte[] toEncrypt = Encoding.UTF8.GetBytes(text);

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

                    // Ending the using statement for the CryptoStream completes the encryption.
                }

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

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

    public static string DecryptTextFromMemory(byte[] encrypted, byte[] key, byte[] iv)
    {
        try
        {
            // Create a buffer to hold the decrypted data.
            // TripleDES-encrypted data will always be slightly bigger than the decrypted data.
            byte[] decrypted = new byte[encrypted.Length];
            int offset = 0;

            // Create a new MemoryStream using the provided array of encrypted data.
            using (MemoryStream mStream = new MemoryStream(encrypted))
            {
                // Create a new TripleDES object.
                using (TripleDES tripleDes = TripleDES.Create())
                // Create a TripleDES decryptor from the key and IV
                using (ICryptoTransform decryptor = tripleDes.CreateDecryptor(key, iv))
                // Create a CryptoStream using the MemoryStream and decryptor
                using (var cStream = new CryptoStream(mStream, decryptor, CryptoStreamMode.Read))
                {
                    // Keep reading from the CryptoStream until it finishes (returns 0).
                    int read = 1;

                    while (read > 0)
                    {
                        read = cStream.Read(decrypted, offset, decrypted.Length - offset);
                        offset += read;
                    }
                }
            }

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

Module MemorySample

    Sub Main()
        Try
            Dim key As Byte()
            Dim iv As Byte()

            ' Create a new TripleDES object to generate a key
            ' and initialization vector (IV).
            Using tripleDes As TripleDES = TripleDES.Create
                key = tripleDes.Key
                iv = tripleDes.IV
            End Using

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

            ' Encrypt the string to an in-memory buffer.
            Dim encrypted As Byte() = EncryptTextToMemory(original, key, iv)

            ' Decrypt the buffer back to a string.
            Dim decrypted As String = DecryptTextFromMemory(encrypted, key, iv)

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


    Function EncryptTextToMemory(text As String, key As Byte(), iv As Byte()) As Byte()
        Try
            ' Create a MemoryStream.
            Using mStream As New MemoryStream
                ' Create a new TripleDES object,
                ' Create a TripleDES encryptor from the key and IV,
                ' Create a CryptoStream using the MemoryStream And encryptor
                Using tripleDes As TripleDES = TripleDES.Create,
                    encryptor As ICryptoTransform = tripleDes.CreateEncryptor(key, iv),
                    cStream = New CryptoStream(mStream, encryptor, CryptoStreamMode.Write)

                    ' Convert the passed string to a byte array.
                    Dim toEncrypt As Byte() = Encoding.UTF8.GetBytes(text)

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

                    ' Ending the using block for the CryptoStream completes the encryption.
                End Using

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

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


    Function DecryptTextFromMemory(encrypted As Byte(), key As Byte(), iv As Byte()) As String
        Try
            ' Create a buffer to hold the decrypted data.
            ' TripleDES-encrypted data will always be slightly bigger than the decrypted data.
            Dim decrypted(encrypted.Length - 1) As Byte
            Dim offset As Integer = 0

            ' Create a new MemoryStream using the provided array of encrypted data.
            ' Create a new TripleDES object.
            ' Create a TripleDES decryptor from the key and IV
            ' Create a CryptoStream using the MemoryStream and decryptor
            Using mStream As New MemoryStream(encrypted),
                tripleDes As TripleDES = TripleDES.Create,
                decryptor As ICryptoTransform = tripleDes.CreateDecryptor(key, iv),
                cStream = New CryptoStream(mStream, decryptor, CryptoStreamMode.Read)

                ' Keep reading from the CryptoStream until it finishes (returns 0).
                Dim read As Integer = 1

                While (read > 0)
                    read = cStream.Read(decrypted, offset, decrypted.Length - offset)
                    offset += read
                End While
            End Using

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

備註

TripleDES 使用演算法的三次連續迭代 DES 。 它可以使用兩個或三個 56 位元金鑰。

Note

一種更新的對稱加密演算法——先進加密標準(AES)——也可用。 考慮使用 該 Aes 類別及其衍生類別,而非類別本身 TripleDES 。 僅用於 TripleDES 與舊有應用程式及資料相容性。

此演算法支援從 128 位元到 192 位元的金鑰長度,且以 64 位元為單位遞增。

建構函式

名稱 Description
TripleDES()

初始化 TripleDES 類別的新執行個體。

欄位

名稱 Description
BlockSizeValue

代表密碼運算的區塊大小(位元)。

(繼承來源 SymmetricAlgorithm)
FeedbackSizeValue

代表密碼運算的反饋大小(位元)。

(繼承來源 SymmetricAlgorithm)
IVValue

代表對稱演算法的初始化向量(IV)。

(繼承來源 SymmetricAlgorithm)
KeySizeValue

代表對稱演算法所使用的秘密金鑰的大小(以位元為單位)。

(繼承來源 SymmetricAlgorithm)
KeyValue

代表對稱演算法的祕密金鑰。

(繼承來源 SymmetricAlgorithm)
LegalBlockSizesValue

指定對稱演算法所支援的區塊大小(位元)。

(繼承來源 SymmetricAlgorithm)
LegalKeySizesValue

指定對稱演算法所支援的金鑰大小(位元)。

(繼承來源 SymmetricAlgorithm)
ModeValue

代表對稱演算法中使用的密碼模式。

(繼承來源 SymmetricAlgorithm)
PaddingValue

代表對稱演算法中使用的填充模式。

(繼承來源 SymmetricAlgorithm)

屬性

名稱 Description
BlockSize

取得或設定密碼運算的區塊大小(位元)。

(繼承來源 SymmetricAlgorithm)
FeedbackSize

取得或設定密碼反饋(CFB)與輸出反饋(OFB)密碼模式的反饋大小(位元)。

(繼承來源 SymmetricAlgorithm)
IV

取得或設定對稱演算法的初始化向量(IV)。

(繼承來源 SymmetricAlgorithm)
Key

取得或設定演算法的 TripleDES 秘密金鑰。

KeySize

取得或設定對稱演算法所使用的秘密金鑰的大小(以位元為單位)。

(繼承來源 SymmetricAlgorithm)
LegalBlockSizes

取得對稱演算法所支援的區塊大小(位元)。

LegalBlockSizes

取得對稱演算法所支援的區塊大小(位元)。

(繼承來源 SymmetricAlgorithm)
LegalKeySizes

取得對稱演算法所支援的金鑰大小(位元)。

LegalKeySizes

取得對稱演算法所支援的金鑰大小(位元)。

(繼承來源 SymmetricAlgorithm)
Mode

取得或設定對稱演算法的運作模式。

(繼承來源 SymmetricAlgorithm)
Padding

取得或設定對稱演算法中使用的填充模式。

(繼承來源 SymmetricAlgorithm)

方法

名稱 Description
Clear()

釋放 SymmetricAlgorithm 類別所使用的所有資源。

(繼承來源 SymmetricAlgorithm)
Create()

建立一個密碼物件實例來執行演算法 TripleDES

Create(String)
已淘汰.

建立一個密碼物件實例,以執行演算法指定的實作 TripleDES

CreateDecryptor()

建立一個對稱解密物件,其目前 Key 屬性與初始化向量IV()。

(繼承來源 SymmetricAlgorithm)
CreateDecryptor(Byte[], Byte[])

當在導出類別中覆寫時,會產生具有指定 Key 性質和初始化向量(IV)的對稱解密物件。

(繼承來源 SymmetricAlgorithm)
CreateEncryptor()

建立一個對稱加密物件,其目前 Key 屬性為 ,初始化向量為 (IV)。

(繼承來源 SymmetricAlgorithm)
CreateEncryptor(Byte[], Byte[])

當在派生類別中覆寫時,會產生具有指定 Key 屬性和初始化向量(IV)的對稱加密物件。

(繼承來源 SymmetricAlgorithm)
DecryptCbc(Byte[], Byte[], PaddingMode)

透過指定的填充模式(CBC)解密資料。

(繼承來源 SymmetricAlgorithm)
DecryptCbc(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, PaddingMode)

透過指定的填充模式(CBC)解密資料。

(繼承來源 SymmetricAlgorithm)
DecryptCbc(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Span<Byte>, PaddingMode)

將資料解密到指定的緩衝區,使用 CBC 模式並搭配指定的填充模式。

(繼承來源 SymmetricAlgorithm)
DecryptCfb(Byte[], Byte[], PaddingMode, Int32)

透過CFB模式解密資料,並依照指定的填充模式和回饋大小進行解密。

(繼承來源 SymmetricAlgorithm)
DecryptCfb(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, PaddingMode, Int32)

透過CFB模式解密資料,並依照指定的填充模式和回饋大小進行解密。

(繼承來源 SymmetricAlgorithm)
DecryptCfb(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Span<Byte>, PaddingMode, Int32)

將資料解密到指定的緩衝區,使用CFB模式,並使用指定的填充模式和回饋大小。

(繼承來源 SymmetricAlgorithm)
DecryptEcb(Byte[], PaddingMode)

透過ECB模式及指定的填充模式解密資料。

(繼承來源 SymmetricAlgorithm)
DecryptEcb(ReadOnlySpan<Byte>, PaddingMode)

透過ECB模式及指定的填充模式解密資料。

(繼承來源 SymmetricAlgorithm)
DecryptEcb(ReadOnlySpan<Byte>, Span<Byte>, PaddingMode)

將資料解密到指定的緩衝區,使用 ECB 模式並搭配指定的填充模式。

(繼承來源 SymmetricAlgorithm)
Dispose()

釋放目前類別實例 SymmetricAlgorithm 所使用的所有資源。

(繼承來源 SymmetricAlgorithm)
Dispose(Boolean)

釋放 未管理的資源, SymmetricAlgorithm 並可選擇性地釋放受管理資源。

(繼承來源 SymmetricAlgorithm)
EncryptCbc(Byte[], Byte[], PaddingMode)

以 CBC 模式並指定填充模式加密資料。

(繼承來源 SymmetricAlgorithm)
EncryptCbc(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, PaddingMode)

以 CBC 模式並指定填充模式加密資料。

(繼承來源 SymmetricAlgorithm)
EncryptCbc(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Span<Byte>, PaddingMode)

將資料加密到指定的緩衝區,使用 CBC 模式並搭配指定的填充模式。

(繼承來源 SymmetricAlgorithm)
EncryptCfb(Byte[], Byte[], PaddingMode, Int32)

使用CFB模式加密資料,並配合指定的填充模式與回饋大小。

(繼承來源 SymmetricAlgorithm)
EncryptCfb(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, PaddingMode, Int32)

使用CFB模式加密資料,並配合指定的填充模式與回饋大小。

(繼承來源 SymmetricAlgorithm)
EncryptCfb(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Span<Byte>, PaddingMode, Int32)

將資料加密到指定的緩衝區,使用 CFB 模式,並符合指定的填充模式與反饋大小。

(繼承來源 SymmetricAlgorithm)
EncryptEcb(Byte[], PaddingMode)

以ECB模式加密資料,並搭配指定的填充模式。

(繼承來源 SymmetricAlgorithm)
EncryptEcb(ReadOnlySpan<Byte>, PaddingMode)

以ECB模式加密資料,並搭配指定的填充模式。

(繼承來源 SymmetricAlgorithm)
EncryptEcb(ReadOnlySpan<Byte>, Span<Byte>, PaddingMode)

將資料加密到指定的緩衝區,使用 ECB 模式並搭配指定的填充模式。

(繼承來源 SymmetricAlgorithm)
Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GenerateIV()

當在導出類別中覆寫時,會產生一個隨機初始化向量(IV)作為演算法的使用。

(繼承來源 SymmetricAlgorithm)
GenerateKey()

當在導出類別中覆寫時,會產生一個隨機鍵(Key)用於該演算法。

(繼承來源 SymmetricAlgorithm)
GetCiphertextLengthCbc(Int32, PaddingMode)

取得密文在特定填充模式下的長度,以及在 CBC 模式下的明文長度。

(繼承來源 SymmetricAlgorithm)
GetCiphertextLengthCfb(Int32, PaddingMode, Int32)

取得密文在特定填充模式下的長度,以及在 CFB 模式下的明文長度。

(繼承來源 SymmetricAlgorithm)
GetCiphertextLengthEcb(Int32, PaddingMode)

取得密文在特定填充模式下的長度,以及在 ECB 模式下的明文長度。

(繼承來源 SymmetricAlgorithm)
GetHashCode()

做為預設哈希函式。

(繼承來源 Object)
GetType()

取得目前實例的 Type

(繼承來源 Object)
IsWeakKey(Byte[])

判斷指定金鑰是否為弱鍵。

MemberwiseClone()

建立目前 Object的淺層複本。

(繼承來源 Object)
SetKey(ReadOnlySpan<Byte>)

設定此實例的金鑰。

(繼承來源 SymmetricAlgorithm)
SetKeyCore(ReadOnlySpan<Byte>)

設定此實例的金鑰。

(繼承來源 SymmetricAlgorithm)
ToString()

傳回表示目前 物件的字串。

(繼承來源 Object)
TryDecryptCbc(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Span<Byte>, Int32, PaddingMode)

嘗試將資料解密到指定的緩衝區,使用 CBC 模式並搭配指定的填充模式。

(繼承來源 SymmetricAlgorithm)
TryDecryptCbcCore(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Span<Byte>, PaddingMode, Int32)

當在派生類別中被覆寫時,會嘗試將資料解密到指定的緩衝區,使用 CBC 模式並搭配指定的填充模式。

(繼承來源 SymmetricAlgorithm)
TryDecryptCfb(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Span<Byte>, Int32, PaddingMode, Int32)

嘗試將資料解密到指定的緩衝區,使用指定的填充模式與反饋大小的 CFB 模式。

(繼承來源 SymmetricAlgorithm)
TryDecryptCfbCore(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Span<Byte>, PaddingMode, Int32, Int32)

當在派生類別中覆寫時,嘗試將資料解密到指定的緩衝區,使用指定的填充模式與反饋大小的 CFB 模式。

(繼承來源 SymmetricAlgorithm)
TryDecryptEcb(ReadOnlySpan<Byte>, Span<Byte>, PaddingMode, Int32)

嘗試將資料解密到指定的緩衝區,使用 ECB 模式並搭配指定的填充模式。

(繼承來源 SymmetricAlgorithm)
TryDecryptEcbCore(ReadOnlySpan<Byte>, Span<Byte>, PaddingMode, Int32)

當在派生類別中覆寫時,會嘗試將資料解密到指定的緩衝區,使用 ECB 模式並搭配指定的填充模式。

(繼承來源 SymmetricAlgorithm)
TryEncryptCbc(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Span<Byte>, Int32, PaddingMode)

嘗試將資料加密到指定的緩衝區,使用 CBC 模式並搭配指定的填充模式。

(繼承來源 SymmetricAlgorithm)
TryEncryptCbcCore(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Span<Byte>, PaddingMode, Int32)

當在派生類別中覆寫時,會嘗試將資料加密到指定的緩衝區,使用 CBC 模式並搭配指定的填充模式。

(繼承來源 SymmetricAlgorithm)
TryEncryptCfb(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Span<Byte>, Int32, PaddingMode, Int32)

嘗試將資料加密到指定的緩衝區,使用指定的填充模式與反饋大小的 CFB 模式。

(繼承來源 SymmetricAlgorithm)
TryEncryptCfbCore(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Span<Byte>, PaddingMode, Int32, Int32)

當在派生類別中覆寫時,嘗試將資料加密到指定的緩衝區,使用 CFB 模式,並搭配指定的填充模式和反饋大小。

(繼承來源 SymmetricAlgorithm)
TryEncryptEcb(ReadOnlySpan<Byte>, Span<Byte>, PaddingMode, Int32)

嘗試將資料加密到指定的緩衝區,使用 ECB 模式並搭配指定的填充模式。

(繼承來源 SymmetricAlgorithm)
TryEncryptEcbCore(ReadOnlySpan<Byte>, Span<Byte>, PaddingMode, Int32)

當在派生類別中覆寫時,會嘗試將資料加密到指定的緩衝區,使用 ECB 模式並搭配指定的填充模式。

(繼承來源 SymmetricAlgorithm)
ValidKeySize(Int32)

判斷指定金鑰大小是否適用於目前演算法。

(繼承來源 SymmetricAlgorithm)

明確介面實作

名稱 Description
IDisposable.Dispose()

此 API 支援此產品基礎結構,但無法直接用於程式碼之中。

釋放 未管理的資源, SymmetricAlgorithm 並可選擇性地釋放受管理資源。

(繼承來源 SymmetricAlgorithm)

適用於

另請參閱