You are developing a method to decrypt data that was encrypted with the TripleDESAlgorithm. <
The method accepts the following parameters:
The byte array to be decrypted, which is named cipherMessage The key, which is named key
An 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 = new TripleDESCryptoServiceProvider();
des.BlockSize = cipherMessage.Length;
ICryptoTransForm crypto = des.CreateEncryptor(Key, iv);
MemoryStream cipherStream = new MemoryStream(cipherMessage);
CryptoStream cryptoStream = new CryptoStream(cipherStream, crypto, CryptoStreamMode.Read);
string message;
message = new StreamReader(cryptoStreamMode).ReadToEnd();
B.
TripleDES des = new TripleDESCryptoServiceProvider();
des.FeedbackSize = cipherMessage.Length;
ICryptoTransForm crypto = des.CreateDecryptor(Key, iv);
MemoryStream cipherStream = new MemoryStream(cipherMessage);
CryptoStream cryptoStream = new CryptoStream(cipherStream, crypto, CryptoStreamMode.Read);
string message;
message = new StreamReader(cryptoStream).ReadToEnd();
C.
TripleDES des = new TripleDESCryptoServiceProvider();
ICryptoTransForm crypto = des.CreateDecryptor();
MemoryStream cipherStream = new MemoryStream(cipherMessage);
CryptoStream cryptoStream = new CryptoStream(cipherStream, crypto, CryptoStreamMode.Read);
string message;
message = new StreamReader(cryptoStream).ReadToEnd();
D.
TripleDES des = new TripleDESCryptoServiceProvider();
ICryptoTransForm crypto = des.CreateDecryptor(Key, iv);
MemoryStream cipherStream = new MemoryStream(cipherMessage);
CryptoStream cryptoStream = new CryptoStream(cipherStream, crypto, CryptoStreamMode.Read);
string message;
message = new StreamReader(cryptoStream).ReadToEnd();
Explanation:
D w�re richtig mit …CreateDecryptor im Orginal steht CreateEncryptor
Frage 56 D w�re richtig mit …CreateDecryptor (sonst B ? .FeedbackSize falsch angegeben ?)
1. Zeile �berall gleich und richtig TripleDES des = new TripleDESCryptoServiceProvider();
2. BlockSize bzw. FeedbackSize (SymmetricAlgorithm) FALSCH da in BIT !!! (m�ssen NICHT angegeben werden(A,B ) )?
3. Umwandler erstellen: ICryptoTransForm crypto = des.CreateDecryptor(Key, iv); Achtung (A und D falsch) des.CreateEncryptor ( wir wollen aber entschl�sseln) !!!
4. Stream zum Lesen der ByteArray � �berall richtig: MemoryStream cipherStream = new MemoryStream(cipherMessage);
5. CryptoStream auf Basis des MemoryStreams erstellen (�berall richtig): CryptoStream cryptoStream = new CryptoStream(cipherStream, crypto, CryptoStreamMode.Read);
6. String f�r Ergebnis erstellen message = new StreamReader(cryptoStream).ReadToEnd();
Tippfehler in (A � falsch): … new StreamReader(cryptoStreamMode)…
I have the same idea. D