質問編集履歴

1

文法の修正

2021/11/01 15:50

投稿

tehori
tehori

スコア1

test CHANGED
File without changes
test CHANGED
@@ -58,7 +58,7 @@
58
58
 
59
59
  Sample sample = new Sample();
60
60
 
61
- Console.WriteLine(sample.DecS("RYlIxh5X8ktRsFuquVPeFiP2qP","wns the ow"));
61
+ Console.WriteLine(sample.Decode("...","aaa"));
62
62
 
63
63
 
64
64
 
@@ -68,21 +68,21 @@
68
68
 
69
69
 
70
70
 
71
- private string DecS(string text, string p)
71
+ private string Decode(string text, string p)
72
72
 
73
73
  {
74
74
 
75
- System.Security.Cryptography.RijndaelManaged _rijndeal = new System.Security.Cryptography.RijndaelManaged();
75
+ System.Security.Cryptography.RijndaelManaged _rijndael = new System.Security.Cryptography.RijndaelManaged();
76
76
 
77
77
 
78
78
 
79
79
  byte[] _key, _iv;
80
80
 
81
- GenerateKeyFromPassWord(p, _rijndeal.KeySize, out _key, _rijndeal.BlockSize, out _iv);
81
+ GenerateKeyFromPassWord(p, _rijndael.KeySize, out _key, _rijndael.BlockSize, out _iv);
82
82
 
83
- _rijndeal.Key = _key;
83
+ _rijndael.Key = _key;
84
84
 
85
- _rijndeal.IV = _iv;
85
+ _rijndael.IV = _iv;
86
86
 
87
87
 
88
88
 
@@ -90,7 +90,7 @@
90
90
 
91
91
 
92
92
 
93
- System.Security.Cryptography.ICryptoTransform _decryptor = _rijndeal.CreateDecryptor();
93
+ System.Security.Cryptography.ICryptoTransform _decryptor = _rijndael.CreateDecryptor();
94
94
 
95
95
 
96
96
 
@@ -106,23 +106,21 @@
106
106
 
107
107
 
108
108
 
109
- public static void GenerateKeyFromPassWord(string pass, int keySize, out byte[] key, int blockSize, out byte[] iv)
109
+ public static void GKFP(string pass, int keySize, out byte[] key, int blockSize, out byte[] iv)
110
110
 
111
111
  {
112
112
 
113
- byte[] _salt = System.Text.Encoding.UTF8.GetBytes("これがsaltとなります");
113
+ byte[] _salt = System.Text.Encoding.UTF8.GetBytes("・・・");
114
114
 
115
115
 
116
116
 
117
- System.Security.Cryptography.Rfc2898DeriveBytes _deviceBytes = new System.Security.Cryptography.Rfc2898DeriveBytes(pass, _salt);
117
+ System.Security.Cryptography.Rfc2898DeriveBytes _deviceBytes = new System.Security.Cryptography.Rfc2898DeriveBytes(password, _salt);
118
118
 
119
- _deviceBytes.IterationCount = 1000;
119
+
120
120
 
121
+ key = _deviceBytes.GetBytes(keySize);
121
122
 
122
-
123
- key = _deviceBytes.GetBytes(keySize / 8);
124
-
125
- iv = _deviceBytes.GetBytes(blockSize / 8);
123
+ iv = _deviceBytes.GetBytes(blockSize);
126
124
 
127
125
  }
128
126