You are developing a method to encrypt sensitive data with the Data Encryption Standard (DES)
algorithm. Your method accepts the following parameters:
The byte array to be encrypted, which is named messageAn encryption key, which is named
keyAn initialization vector, which is named iv
You need to encrypt the data. You also need to write the encrypted data to a MemoryStream
object.
Which code segment should you use?
A. DES des = new DESCryptoServiceProvider();
des.BlockSize = message.Length;ICryptoTransform crypto = des.CreateEncryptor(key, iv);
MemoryStream cipherStream = new MemoryStream();
CryptoStream cryptoStream = new CryptoStream(cipherStream,
crypto, CryptoStreamMode.Write);
cryptoStream.Write(message, 0, message.Length);
B. DES des = new DESCryptoServiceProvider();
ICryptoTransform crypto = des.CreateDecryptor(key, iv);
MemoryStream cipherStream = new MemoryStream();CryptoStream cryptoStream =
new CryptoStream(cipherStream,
crypto, CryptoStreamMode.Write);
cryptoStream.Write(message, 0, message.Length);
C. DES des = new DESCryptoServiceProvider();ICryptoTransform crypto =
des.CreateEncryptor();
MemoryStream cipherStream = new MemoryStream();CryptoStream cryptoStream =
new CryptoStream(cipherStream,
crypto, CryptoStreamMode.Write);
cryptoStream.Write(message, 0, message.Length);
D. DES des = new DESCryptoServiceProvider();ICryptoTransform crypto =
des.CreateEncryptor(key, iv);
MemoryStream cipherStream = new MemoryStream();CryptoStream cryptoStream =
new CryptoStream(cipherStream, crypto, CryptoStreamMode.Write);cryptoStream.Write(message, 0, message.Length);
Answer: D
algorithm. Your method accepts the following parameters:
The byte array to be encrypted, which is named messageAn encryption key, which is named
keyAn initialization vector, which is named iv
You need to encrypt the data. You also need to write the encrypted data to a MemoryStream
object.
Which code segment should you use?
A. DES des = new DESCryptoServiceProvider();
des.BlockSize = message.Length;ICryptoTransform crypto = des.CreateEncryptor(key, iv);
MemoryStream cipherStream = new MemoryStream();
CryptoStream cryptoStream = new CryptoStream(cipherStream,
crypto, CryptoStreamMode.Write);
cryptoStream.Write(message, 0, message.Length);
B. DES des = new DESCryptoServiceProvider();
ICryptoTransform crypto = des.CreateDecryptor(key, iv);
MemoryStream cipherStream = new MemoryStream();CryptoStream cryptoStream =
new CryptoStream(cipherStream,
crypto, CryptoStreamMode.Write);
cryptoStream.Write(message, 0, message.Length);
C. DES des = new DESCryptoServiceProvider();ICryptoTransform crypto =
des.CreateEncryptor();
MemoryStream cipherStream = new MemoryStream();CryptoStream cryptoStream =
new CryptoStream(cipherStream,
crypto, CryptoStreamMode.Write);
cryptoStream.Write(message, 0, message.Length);
D. DES des = new DESCryptoServiceProvider();ICryptoTransform crypto =
des.CreateEncryptor(key, iv);
MemoryStream cipherStream = new MemoryStream();CryptoStream cryptoStream =
new CryptoStream(cipherStream, crypto, CryptoStreamMode.Write);cryptoStream.Write(message, 0, message.Length);
Answer: D
No comments:
Post a Comment