RC2CryptoServiceProvider.UseSalt プロパティ
アセンブリ: mscorlib (mscorlib.dll 内)

Dim instance As RC2CryptoServiceProvider Dim value As Boolean value = instance.UseSalt instance.UseSalt = value
/** @property */ public boolean get_UseSalt () /** @property */ public void set_UseSalt (boolean value)
11 バイト長、値 0 の salt を使用してキーを作成する場合は true。それ以外の場合は、false。既定値は false です。

UseSalt プロパティを使用すると、11 バイト長、値 0 の salt を使用する既存のアプリケーションを相互運用できます。ほとんどの場合、RC2CryptoServiceProvider キーには salt を使用しません。

次のコード例では、UseSalt プロパティを true に設定し、値を暗号化した後、復号化します。
Imports System Imports System.IO Imports System.Text Imports System.Security.Cryptography Module MyMainModule Sub Main() Dim originalBytes As Byte() = ASCIIEncoding.ASCII.GetBytes("Here is some data.") 'Create a new RC2CryptoServiceProvider. Dim rc2CSP As New RC2CryptoServiceProvider() rc2CSP.UseSalt = True rc2CSP.GenerateKey() rc2CSP.GenerateIV() 'Encrypt the data. Dim msEncrypt As New MemoryStream() Dim csEncrypt As New CryptoStream(msEncrypt, rc2CSP.CreateEncryptor(rc2CSP.Key, rc2CSP.IV), CryptoStreamMode.Write) 'Write all data to the crypto stream and flush it. csEncrypt.Write(originalBytes, 0, originalBytes.Length) csEncrypt.FlushFinalBlock() 'Get encrypted array of bytes. Dim encryptedBytes As Byte() = msEncrypt.ToArray() 'Decrypt the previously encrypted message. Dim msDecrypt As New MemoryStream(encryptedBytes) Dim csDecrypt As New CryptoStream(msDecrypt, rc2CSP.CreateDecryptor(rc2CSP.Key, rc2CSP.IV), CryptoStreamMode.Read) Dim unencryptedBytes(originalBytes.Length) As Byte 'Read the data out of the crypto stream. csDecrypt.Read(unencryptedBytes, 0, unencryptedBytes.Length) 'Convert the byte array back into a string. Dim plaintext As String = ASCIIEncoding.ASCII.GetString(unencryptedBytes) 'Display the results. Console.WriteLine("Unencrypted text: {0}", plaintext) Console.ReadLine() End Sub End Module
using System; using System.IO; using System.Text; using System.Security.Cryptography; namespace RC2CryptoServiceProvider_Examples { class MyMainClass { public static void Main() { byte[] originalBytes = ASCIIEncoding.ASCII.GetBytes("Here is some data."); //Create a new RC2CryptoServiceProvider. RC2CryptoServiceProvider rc2CSP = new RC2CryptoServiceProvider(); rc2CSP.UseSalt = true; rc2CSP.GenerateKey(); rc2CSP.GenerateIV(); //Encrypt the data. MemoryStream msEncrypt = new MemoryStream(); CryptoStream csEncrypt = new CryptoStream(msEncrypt, rc2CSP.CreateEncryptor(rc2CSP.Key, rc2CSP.IV), CryptoStreamMode.Write); //Write all data to the crypto stream and flush it. csEncrypt.Write(originalBytes, 0, originalBytes.Length); csEncrypt.FlushFinalBlock(); //Get encrypted array of bytes. byte[] encryptedBytes = msEncrypt.ToArray(); //Decrypt the previously encrypted message. MemoryStream msDecrypt = new MemoryStream(encryptedBytes); CryptoStream csDecrypt = new CryptoStream(msDecrypt, rc2CSP.CreateDecryptor(rc2CSP.Key, rc2CSP.IV), CryptoStreamMode.Read); byte[] unencryptedBytes = new byte[originalBytes.Length]; //Read the data out of the crypto stream. csDecrypt.Read(unencryptedBytes, 0, unencryptedBytes.Length); //Convert the byte array back into a string. string plaintext = ASCIIEncoding.ASCII.GetString(unencryptedBytes); //Display the results. Console.WriteLine("Unencrypted text: {0}", plaintext); Console.ReadLine(); } } }
using namespace System; using namespace System::IO; using namespace System::Text; using namespace System::Security::Cryptography; int main() { array <Byte>^ originalBytes = ASCIIEncoding::ASCII->GetBytes("Here is some data."); //Create a new RC2CryptoServiceProvider. RC2CryptoServiceProvider^ rc2Provider = gcnew RC2CryptoServiceProvider(); rc2Provider->UseSalt = true; rc2Provider->GenerateKey(); rc2Provider->GenerateIV(); //Encrypt the data. MemoryStream^ encryptionMemoryStream = gcnew MemoryStream(); CryptoStream^ encryptionCryptoStream = gcnew CryptoStream( encryptionMemoryStream, rc2Provider->CreateEncryptor( rc2Provider->Key, rc2Provider->IV), CryptoStreamMode::Write); //Write all data to the crypto stream and flush it. encryptionCryptoStream->Write(originalBytes, 0, originalBytes->Length); encryptionCryptoStream->FlushFinalBlock(); //Get encrypted array of bytes. array<Byte>^ encryptedBytes = encryptionMemoryStream->ToArray(); //Decrypt the previously encrypted message. MemoryStream^ decryptionMemoryStream = gcnew MemoryStream(encryptedBytes); CryptoStream^ decryptionCryptoStream = gcnew CryptoStream(decryptionMemoryStream, rc2Provider->CreateDecryptor(rc2Provider->Key,rc2Provider->IV), CryptoStreamMode::Read); array<Byte>^ unencryptedBytes = gcnew array<Byte>(originalBytes->Length); //Read the data out of the crypto stream. decryptionCryptoStream->Read(unencryptedBytes, 0, unencryptedBytes->Length); //Convert the byte array back into a string. String^ plainText = ASCIIEncoding::ASCII->GetString(unencryptedBytes); //Display the results. Console::WriteLine("Unencrypted text: {0}", plainText); Console::ReadLine(); }

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からRC2CryptoServiceProvider.UseSalt プロパティを検索する場合は、下記のリンクをクリックしてください。

- RC2CryptoServiceProvider.UseSalt プロパティのページへのリンク