teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

誤字、文法修正

2021/11/01 15:55

投稿

tehori
tehori

スコア1

title CHANGED
File without changes
body CHANGED
@@ -21,23 +21,23 @@
21
21
  static void Main()
22
22
  {
23
23
 
24
- Console.WriteLine(DecS("RYlIxh5X8ktRsFuquVPeFiP2qPTgCTSrSNZsM+PPCS5BuHnBITZi4TMVbyXTx2LK+rtkCkD9VpB+/J1XSOGTjNuLUBSmVSPP/vHIX8W6LIcyd+XSocFDm5tTy0i/XQoTBR5wxzyCgmY8fEkM","wns the ow"));
24
+ Console.WriteLine(Decode("・・・","aaaa"));
25
25
 
26
26
 
27
27
  }
28
28
 
29
- private string DecS(string text, string p)
29
+ private string Decode(string text, string p)
30
30
  {
31
- System.Security.Cryptography.RijndaelManaged _rijndeal = new System.Security.Cryptography.RijndaelManaged();
31
+ System.Security.Cryptography.RijndaelManaged _rijndael = new System.Security.Cryptography.RijndaelManaged();
32
32
 
33
33
  byte[] _key, _iv;
34
- GenerateKeyFromPassWord(p, _rijndeal.KeySize, out _key, _rijndeal.BlockSize, out _iv);
34
+ GKFP(p, _rijndael.KeySize, out _key, _rijndael.BlockSize, out _iv);
35
- _rijndeal.Key = _key;
35
+ _rijndael.Key = _key;
36
- _rijndeal.IV = _iv;
36
+ _rijndael.IV = _iv;
37
37
 
38
38
  byte[] _strByte = System.Convert.FromBase64String(text);
39
39
 
40
- System.Security.Cryptography.ICryptoTransform _decryptor = _rijndeal.CreateDecryptor();
40
+ System.Security.Cryptography.ICryptoTransform _decryptor = _rijndael.CreateDecryptor();
41
41
 
42
42
  byte[] _decByte = _decryptor.TransformFinalBlock(_strByte, 0, _strByte.Length);
43
43
  _decryptor.Dispose();
@@ -45,15 +45,15 @@
45
45
  return System.Text.Encoding.UTF8.GetString(_decByte);
46
46
  }
47
47
 
48
- public static void GenerateKeyFromPassWord(string pass, int keySize, out byte[] key, int blockSize, out byte[] iv)
48
+ public static void GKFP(string pass, int keySize, out byte[] key, int blockSize, out byte[] iv)
49
49
  {
50
- byte[] _salt = System.Text.Encoding.UTF8.GetBytes("これがsaltとなります");
50
+ byte[] _salt = System.Text.Encoding.UTF8.GetBytes("・・・");
51
51
 
52
52
  System.Security.Cryptography.Rfc2898DeriveBytes _deviceBytes = new System.Security.Cryptography.Rfc2898DeriveBytes(pass, _salt);
53
- _deviceBytes.IterationCount = 1000;
53
+
54
54
 
55
- key = _deviceBytes.GetBytes(keySize / 8);
55
+ key = _deviceBytes.GetBytes(keySize);
56
- iv = _deviceBytes.GetBytes(blockSize / 8);
56
+ iv = _deviceBytes.GetBytes(blockSize);
57
57
  }
58
58
  }
59
59
  }