質問編集履歴

1

誤字、文法修正

2021/11/01 15:55

投稿

tehori
tehori

スコア1

test CHANGED
File without changes
test CHANGED
@@ -44,7 +44,7 @@
44
44
 
45
45
 
46
46
 
47
- Console.WriteLine(DecS("RYlIxh5X8ktRsFuquVPeFiP2qPTgCTSrSNZsM+PPCS5BuHnBITZi4TMVbyXTx2LK+rtkCkD9VpB+/J1XSOGTjNuLUBSmVSPP/vHIX8W6LIcyd+XSocFDm5tTy0i/XQoTBR5wxzyCgmY8fEkM","wns the ow"));
47
+ Console.WriteLine(Decode("・・・","aaaa"));
48
48
 
49
49
 
50
50
 
@@ -54,21 +54,21 @@
54
54
 
55
55
 
56
56
 
57
- private string DecS(string text, string p)
57
+ private string Decode(string text, string p)
58
58
 
59
59
  {
60
60
 
61
- System.Security.Cryptography.RijndaelManaged _rijndeal = new System.Security.Cryptography.RijndaelManaged();
61
+ System.Security.Cryptography.RijndaelManaged _rijndael = new System.Security.Cryptography.RijndaelManaged();
62
62
 
63
63
 
64
64
 
65
65
  byte[] _key, _iv;
66
66
 
67
- GenerateKeyFromPassWord(p, _rijndeal.KeySize, out _key, _rijndeal.BlockSize, out _iv);
67
+ GKFP(p, _rijndael.KeySize, out _key, _rijndael.BlockSize, out _iv);
68
68
 
69
- _rijndeal.Key = _key;
69
+ _rijndael.Key = _key;
70
70
 
71
- _rijndeal.IV = _iv;
71
+ _rijndael.IV = _iv;
72
72
 
73
73
 
74
74
 
@@ -76,7 +76,7 @@
76
76
 
77
77
 
78
78
 
79
- System.Security.Cryptography.ICryptoTransform _decryptor = _rijndeal.CreateDecryptor();
79
+ System.Security.Cryptography.ICryptoTransform _decryptor = _rijndael.CreateDecryptor();
80
80
 
81
81
 
82
82
 
@@ -92,23 +92,23 @@
92
92
 
93
93
 
94
94
 
95
- public static void GenerateKeyFromPassWord(string pass, int keySize, out byte[] key, int blockSize, out byte[] iv)
95
+ public static void GKFP(string pass, int keySize, out byte[] key, int blockSize, out byte[] iv)
96
96
 
97
97
  {
98
98
 
99
- byte[] _salt = System.Text.Encoding.UTF8.GetBytes("これがsaltとなります");
99
+ byte[] _salt = System.Text.Encoding.UTF8.GetBytes("・・・");
100
100
 
101
101
 
102
102
 
103
103
  System.Security.Cryptography.Rfc2898DeriveBytes _deviceBytes = new System.Security.Cryptography.Rfc2898DeriveBytes(pass, _salt);
104
104
 
105
- _deviceBytes.IterationCount = 1000;
105
+
106
106
 
107
107
 
108
108
 
109
- key = _deviceBytes.GetBytes(keySize / 8);
109
+ key = _deviceBytes.GetBytes(keySize);
110
110
 
111
- iv = _deviceBytes.GetBytes(blockSize / 8);
111
+ iv = _deviceBytes.GetBytes(blockSize);
112
112
 
113
113
  }
114
114