答案: C
- _- n7 J& `* {% G: M9 {" f# V; B. I1 E
第 49 题 , I! v8 I4 c- G+ B; g( D/ ^
你正在开发一个在网络上传输铭感信息的服务器应用。你创建了一个 X509Certificate 对象
5 V% f; ?2 P+ q+ z; Lcertificate 和一个 TcpClient 对象 client。你需要创建一个 SslStream 对象,从而通过 Transport ; j. y' E! d- D9 ^' Z2 y6 P: |% ]
Layer Security 1.0 协议(TLS 1.0 安全协议)进行通讯。你应该使用那个代码段? % f4 r' B: ?: W
A. SslStream ssl = new SslStream(client.GetStream());ssl.AuthenticateAsServer(certificate,
; G, _8 R& Y9 M ]# ^; ]: o dfalse, SslProtocols.None, true);
5 o: m) d4 r! y' l1 QB. SslStream ssl = new SslStream(client.GetStream());ssl.AuthenticateAsServer(certificate, # x: U- }. I' W" O2 S6 I5 R
false, SslProtocols.Ssl3, true);
; \9 {( D0 |- Z2 S& NC. SslStream ssl = new SslStream(client.GetStream());ssl.AuthenticateAsServer(certificate, " G: r1 J; T, E9 O3 R
false, SslProtocols.Ssl2, true); : v: E# _4 u; o) R
D. SslStream ssl = new SslStream(client.GetStream()); ssl.AuthenticateAsServer(certificate,
6 K* T" S4 R# @( }8 A: ffalse, SslProtocols.Tls, true);
, `6 I$ M( |& i1 m答案: D % ^1 C8 S$ l L1 ~& m
& o* ~% s+ ]$ e3 ~. }/ G
第 50 题 1 j7 w6 A& X1 ?8 y; _0 h
你正在开发一个使用 DES(Data Encryption Standard)算法加密铭感数据的方法。你的方法 A$ D8 c- k Q$ }4 M
接收如下参数:将被加密的字节数组 message,密钥 key,始化向量 iv。
2 I. i4 b: C# s: C& a3 f) ^你需要去加密数据,你也需要把加密数据写入MemoryStream 对象。你应该使用那段代码?
9 K3 V( @1 [# C. K- r* xA. DES des = new DESCryptoServiceProvider();
3 M2 N* U$ s, z* l5 tdes.BlockSize = message.Length;ICryptoTransform crypto = des.CreateEncryptor(key, iv);
) c, U% c& J: O$ C( [! ]MemoryStream cipherStream = new MemoryStream();
0 a& Z7 S/ X/ P% K$ z9 zCryptoStream cryptoStream = new CryptoStream(cipherStream,
7 ~- R* M) I/ ucrypto, CryptoStreamMode.Write); 9 r; G1 S0 q3 D* `2 ^! H' j
cryptoStream.Write(message, 0, message.Length); ) X) [9 ~: Z5 D! C. I9 {
B. DES des = new DESCryptoServiceProvider();
/ W* P- [8 H% A5 ^8 VICryptoTransform crypto = des.CreateDecryptor(key, iv); ( W& d1 z/ W9 B8 [
MemoryStream cipherStream = new MemoryStream();CryptoStream cryptoStream = ' C9 m9 u- S: Y# H5 D: W+ t
new CryptoStream(cipherStream,
; |9 i2 {9 p" q% R0 Jcrypto, CryptoStreamMode.Write); ) [9 f% m7 j9 e* f; {' U8 F
cryptoStream.Write(message, 0, message.Length);
; h3 y; u" b* ~9 ^; A. |, c7 UC. DES des = new DESCryptoServiceProvider();ICryptoTransform crypto = ' a! r, E* c, Q
des.CreateEncryptor(); * E. A$ H6 }6 X
MemoryStream cipherStream = new MemoryStream();CryptoStream cryptoStream = : w4 ?) ]/ ~6 g
new CryptoStream(cipherStream,
" [4 k$ R, q; O- M: u1 `, Ycrypto, CryptoStreamMode.Write);
6 {3 r! g6 _. [, h" ]4 x# fcryptoStream.Write(message, 0, message.Length);
5 d# K+ h2 N; D: ~' c. UD. DES des = new DESCryptoServiceProvider();ICryptoTransform crypto =
% V) B* H& A7 S( h$ B$ gdes.CreateEncryptor(key, iv);
& `4 T6 O) B: s @- s' qMemoryStream cipherStream = new MemoryStream();CryptoStream cryptoStream = 3 H# P: u7 S U. w9 N
new CryptoStream(cipherStream, 6 N( k; g3 M! q9 P$ v
crypto, CryptoStreamMode.Write);cryptoStream.Write(message, 0, message.Length); 3 F. o7 ]0 c3 z/ G2 j
答案: D |