質問編集履歴
1
誤字、文法修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -21,23 +21,23 @@
|
|
21
21
|
static void Main()
|
22
22
|
{
|
23
23
|
|
24
|
-
Console.WriteLine(
|
24
|
+
Console.WriteLine(Decode("・・・","aaaa"));
|
25
25
|
|
26
26
|
|
27
27
|
}
|
28
28
|
|
29
|
-
private string
|
29
|
+
private string Decode(string text, string p)
|
30
30
|
{
|
31
|
-
System.Security.Cryptography.RijndaelManaged
|
31
|
+
System.Security.Cryptography.RijndaelManaged _rijndael = new System.Security.Cryptography.RijndaelManaged();
|
32
32
|
|
33
33
|
byte[] _key, _iv;
|
34
|
-
|
34
|
+
GKFP(p, _rijndael.KeySize, out _key, _rijndael.BlockSize, out _iv);
|
35
|
-
|
35
|
+
_rijndael.Key = _key;
|
36
|
-
|
36
|
+
_rijndael.IV = _iv;
|
37
37
|
|
38
38
|
byte[] _strByte = System.Convert.FromBase64String(text);
|
39
39
|
|
40
|
-
System.Security.Cryptography.ICryptoTransform _decryptor =
|
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
|
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("
|
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
|
-
|
53
|
+
|
54
54
|
|
55
|
-
key = _deviceBytes.GetBytes(keySize
|
55
|
+
key = _deviceBytes.GetBytes(keySize);
|
56
|
-
iv = _deviceBytes.GetBytes(blockSize
|
56
|
+
iv = _deviceBytes.GetBytes(blockSize);
|
57
57
|
}
|
58
58
|
}
|
59
59
|
}
|