You are developing a method to encrypt sensitive data with the Data Encryption Standard (DES) algorithm. Your method accepts the following parameters:

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. Dim objDES As New DESCryptoServiceProviderobjDES.BlockSize =
    message.Length
    Dim objCrypto As ICryptoTransform = obj
    DES.CreateDecryptor(key, iv)
    Dim cipherStream As New MemoryStream
    Dim cryptoStream As New CryptoStream(cipherStream, objCrypto,
    CryptoStreamMode.Write)

B. Dim objDES As New DESCryptoServiceProvider
    Dim objCrypto As ICryptoTransform = objDES.CreateDecryptor(key, iv)Dim
    cipherStream As New MemoryStream
    Dim cryptoStream As New CryptoStream(cipherStream, objCrypto, 
    CryptoStreamMode.Write)
    cryptoStream.Write(message, 0, message.Length)

C. Dim objDES As New DESCryptoServiceProvider
    Dim objCrypto As ICryptoTransform = obj
    DES.CreateDecryptor()
    Dim cipherStream As New MemoryStream
    Dim cryptoStream As New CryptoStream(cipherStream, objCrypto,
    CryptoStreamMode.Write)
    cryptoStream.Write(message, 0, message.Length)

D. Dim objDES As New DESCryptoServiceProvider
    Dim objCrypto As ICryptoTransform = obj
    DES.CreateEncryptor(key, iv)
    Dim cipherStream As New MemoryStream
    Dim cryptoStream As New CryptoStream(cipherStream, objCrypto,
    CryptoStreamMode.Write)
    cryptoStream.Write(message, 0, message.Length)


Answer: D 


No comments:

Post a Comment