質問編集履歴

2

見やすく簡素化

2021/11/02 12:25

投稿

tehori
tehori

スコア1

test CHANGED
File without changes
test CHANGED
@@ -8,38 +8,12 @@
8
8
 
9
9
 
10
10
 
11
- **↓実行して、テキストファイルをドラッグアンドドロップしたときのウィンドウ**
11
+
12
-
13
- ![イメージ説明](367a8a4ec666244bb3da16d27038df61.jpeg)
14
-
15
- **↓D&Dしたテキストファイル**
16
-
17
- ![イメージ説明](a8a666734aeb0ba6af7befffed0d8520.jpeg)
18
12
 
19
13
  ###コード
20
14
 
21
15
  ```C#
22
16
 
23
- using System;
24
-
25
- using System.IO;
26
-
27
- using System.Collections.Generic;
28
-
29
- using System.ComponentModel;
30
-
31
- using System.Data;
32
-
33
- using System.Drawing;
34
-
35
- using System.Linq;
36
-
37
- using System.Text;
38
-
39
- using System.Threading.Tasks;
40
-
41
- using System.Windows.Forms;
42
-
43
17
 
44
18
 
45
19
  namespace WindowsFormsApp2
@@ -156,29 +130,29 @@
156
130
 
157
131
 
158
132
 
159
- private string DecS(string text, string p)
133
+ private string DecS(string text, string pass)
160
-
134
+
161
- {
135
+ {
162
-
136
+
163
- System.Security.Cryptography.RijndaelManaged _rijndeal = new System.Security.Cryptography.RijndaelManaged();
137
+ System.Security.Cryptography.RijndaelManaged _rijndael = new System.Security.Cryptography.RijndaelManaged();
164
138
 
165
139
 
166
140
 
167
141
  byte[] _key, _iv;
168
142
 
169
- GenerateKeyFromPassWord(p, _rijndeal.KeySize, out _key, _rijndeal.BlockSize, out _iv);
143
+ GenerateKeyFromPassWord(pass, _rijndael.KeySize, out _key, _rijndael.BlockSize, out iv);
170
-
144
+
171
- _rijndeal.Key = _key;
145
+ _rijndael.Key = key;
172
-
146
+
173
- _rijndeal.IV = _iv;
147
+ _rijndael.IV = iv;
174
-
175
-
176
-
177
-
178
-
179
-
180
-
148
+
149
+
150
+
151
+
152
+
153
+
154
+
181
- System.Security.Cryptography.ICryptoTransform _decryptor = _rijndeal.CreateDecryptor();
155
+ System.Security.Cryptography.ICryptoTransform _decryptor = _rijndael.CreateDecryptor();
182
156
 
183
157
 
184
158
 
@@ -206,7 +180,7 @@
206
180
 
207
181
  {
208
182
 
209
- byte[] _salt = System.Text.Encoding.UTF8.GetBytes("これがsaltとなります");
183
+ byte[] _salt = System.Text.Encoding.UTF8.GetBytes("・・・");
210
184
 
211
185
 
212
186
 
@@ -216,9 +190,9 @@
216
190
 
217
191
 
218
192
 
219
- key = _deviceBytes.GetBytes(keySize / 8);
193
+ key = _deviceBytes.GetBytes(keySize);
220
-
194
+
221
- iv = _deviceBytes.GetBytes(blockSize / 8);
195
+ iv = _deviceBytes.GetBytes(blockSize);
222
196
 
223
197
  }
224
198
 

1

誤字

2021/11/02 12:25

投稿

tehori
tehori

スコア1

test CHANGED
File without changes
test CHANGED
@@ -122,7 +122,7 @@
122
122
 
123
123
  //ここで復号実行
124
124
 
125
- PlainText = DecS(EncryptedText,"wns the ow");
125
+ PlainText = DecS(EncryptedText,"passwordAAA");
126
126
 
127
127
          //D&Dしたテキストの中身そのまま表示=うまくいく
128
128