質問編集履歴
1
文法の修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -28,23 +28,23 @@
|
|
28
28
|
{
|
29
29
|
|
30
30
|
Sample sample = new Sample();
|
31
|
-
Console.WriteLine(sample.
|
31
|
+
Console.WriteLine(sample.Decode("...","aaa"));
|
32
32
|
|
33
33
|
|
34
34
|
}
|
35
35
|
|
36
|
-
private string
|
36
|
+
private string Decode(string text, string p)
|
37
37
|
{
|
38
|
-
System.Security.Cryptography.RijndaelManaged
|
38
|
+
System.Security.Cryptography.RijndaelManaged _rijndael = new System.Security.Cryptography.RijndaelManaged();
|
39
39
|
|
40
40
|
byte[] _key, _iv;
|
41
|
-
GenerateKeyFromPassWord(p,
|
41
|
+
GenerateKeyFromPassWord(p, _rijndael.KeySize, out _key, _rijndael.BlockSize, out _iv);
|
42
|
-
|
42
|
+
_rijndael.Key = _key;
|
43
|
-
|
43
|
+
_rijndael.IV = _iv;
|
44
44
|
|
45
45
|
byte[] _strByte = System.Convert.FromBase64String(text);
|
46
46
|
|
47
|
-
System.Security.Cryptography.ICryptoTransform _decryptor =
|
47
|
+
System.Security.Cryptography.ICryptoTransform _decryptor = _rijndael.CreateDecryptor();
|
48
48
|
|
49
49
|
byte[] _decByte = _decryptor.TransformFinalBlock(_strByte, 0, _strByte.Length);
|
50
50
|
_decryptor.Dispose();
|
@@ -52,15 +52,14 @@
|
|
52
52
|
return System.Text.Encoding.UTF8.GetString(_decByte);
|
53
53
|
}
|
54
54
|
|
55
|
-
public static void
|
55
|
+
public static void GKFP(string pass, int keySize, out byte[] key, int blockSize, out byte[] iv)
|
56
56
|
{
|
57
|
-
byte[] _salt = System.Text.Encoding.UTF8.GetBytes("
|
57
|
+
byte[] _salt = System.Text.Encoding.UTF8.GetBytes("・・・");
|
58
58
|
|
59
|
-
System.Security.Cryptography.Rfc2898DeriveBytes _deviceBytes = new System.Security.Cryptography.Rfc2898DeriveBytes(
|
59
|
+
System.Security.Cryptography.Rfc2898DeriveBytes _deviceBytes = new System.Security.Cryptography.Rfc2898DeriveBytes(password, _salt);
|
60
|
-
|
60
|
+
|
61
|
-
|
62
|
-
key = _deviceBytes.GetBytes(keySize
|
61
|
+
key = _deviceBytes.GetBytes(keySize);
|
63
|
-
iv = _deviceBytes.GetBytes(blockSize
|
62
|
+
iv = _deviceBytes.GetBytes(blockSize);
|
64
63
|
}
|
65
64
|
}
|
66
65
|
}
|