You are developing a method to decrypt data that was encrypted with the Triple DES Algorithm.
The method accepts the following parameters: The byte array to be decrypted, which is named
cipherMessageThe key, which is named keyAn initialization vector, which is named iv You need
to decrypt the message by using the TripleDES class and place the result in a string. Which code
segment should you use?
A. TripleDES^ des = gcnew TripleDESCryptoServiceProvider();des->BlockSize = cipherMessage-
>Length;
ICryptoTransform^ crypto = des->CreateDecryptor(key, iv);
MemoryStream^ cipherStream = gcnew MemoryStream(cipherMessage);
CryptoStream ^cryptoStream = gcnew CryptoStream(cipherStream, crypto,
CryptoStreamMode::Read);
String^ message;StreamReader^ sReader = gcnew StreamReader(cryptoStream);
message = sReader->ReadToEnd();
B. TripleDES^ des = gcnew TripleDESCryptoServiceProvider();
des->FeedbackSize = cipherMessage->Length;
ICryptoTransform^ crypto = des->CreateDecryptor(key, iv);
MemoryStream^ cipherStream = gcnew MemoryStream(cipherMessage);
CryptoStream^ cryptoStream = gcnew CryptoStream(cipherStream, crypto,
CryptoStreamMode::Read);
String^ message;StreamReader^ sReader = gcnew StreamReader(cryptoStream);
message = sReader->ReadToEnd();
C. TripleDES^ des = gcnew TripleDESCryptoServiceProvider();
ICryptoTransform^ crypto = des->CreateDecryptor();
MemoryStream^ cipherStream = gcnew MemoryStream(cipherMessage);
CryptoStream^ cryptoStream = gcnew CryptoStream(cipherStream, crypto,
CryptoStreamMode::Read);String^ message;
StreamReader^ sReader = gcnew StreamReader(cryptoStream);
message = sReader->ReadToEnd();
D. TripleDES^ des = gcnew TripleDESCryptoServiceProvider();
ICryptoTransform^ crypto = des->CreateDecryptor(key, iv);
MemoryStream^ cipherStream = gcnew MemoryStream(cipherMessage);
CryptoStream^ cryptoStream = gcnew CryptoStream( cipherStream, crypto,
CryptoStreamMode::Read);
String^ message;StreamReader^ sReader = gcnew StreamReader(cryptoStream);
message = sReader->ReadToEnd();
Answer: D
The method accepts the following parameters: The byte array to be decrypted, which is named
cipherMessageThe key, which is named keyAn initialization vector, which is named iv You need
to decrypt the message by using the TripleDES class and place the result in a string. Which code
segment should you use?
A. TripleDES^ des = gcnew TripleDESCryptoServiceProvider();des->BlockSize = cipherMessage-
>Length;
ICryptoTransform^ crypto = des->CreateDecryptor(key, iv);
MemoryStream^ cipherStream = gcnew MemoryStream(cipherMessage);
CryptoStream ^cryptoStream = gcnew CryptoStream(cipherStream, crypto,
CryptoStreamMode::Read);
String^ message;StreamReader^ sReader = gcnew StreamReader(cryptoStream);
message = sReader->ReadToEnd();
B. TripleDES^ des = gcnew TripleDESCryptoServiceProvider();
des->FeedbackSize = cipherMessage->Length;
ICryptoTransform^ crypto = des->CreateDecryptor(key, iv);
MemoryStream^ cipherStream = gcnew MemoryStream(cipherMessage);
CryptoStream^ cryptoStream = gcnew CryptoStream(cipherStream, crypto,
CryptoStreamMode::Read);
String^ message;StreamReader^ sReader = gcnew StreamReader(cryptoStream);
message = sReader->ReadToEnd();
C. TripleDES^ des = gcnew TripleDESCryptoServiceProvider();
ICryptoTransform^ crypto = des->CreateDecryptor();
MemoryStream^ cipherStream = gcnew MemoryStream(cipherMessage);
CryptoStream^ cryptoStream = gcnew CryptoStream(cipherStream, crypto,
CryptoStreamMode::Read);String^ message;
StreamReader^ sReader = gcnew StreamReader(cryptoStream);
message = sReader->ReadToEnd();
D. TripleDES^ des = gcnew TripleDESCryptoServiceProvider();
ICryptoTransform^ crypto = des->CreateDecryptor(key, iv);
MemoryStream^ cipherStream = gcnew MemoryStream(cipherMessage);
CryptoStream^ cryptoStream = gcnew CryptoStream( cipherStream, crypto,
CryptoStreamMode::Read);
String^ message;StreamReader^ sReader = gcnew StreamReader(cryptoStream);
message = sReader->ReadToEnd();
Answer: D
No comments:
Post a Comment