質問編集履歴
1
誤字
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
[
|
1
|
+
[rijndael/C#]復号プログラムをヒントに、暗号プログラムを作成したい
|
body
CHANGED
@@ -15,23 +15,23 @@
|
|
15
15
|
{
|
16
16
|
|
17
17
|
Sample sample = new Sample();
|
18
|
-
Console.WriteLine(sample.DecS(".....(ここに暗号化文を入れる)","
|
18
|
+
Console.WriteLine(sample.DecS(".....(ここに暗号化文を入れる)","aaa"));
|
19
19
|
|
20
20
|
|
21
21
|
}
|
22
22
|
|
23
23
|
private string DecS(string text, string p)
|
24
24
|
{
|
25
|
-
System.Security.Cryptography.RijndaelManaged
|
25
|
+
System.Security.Cryptography.RijndaelManaged _rijndael = new System.Security.Cryptography.RijndaelManaged();
|
26
26
|
|
27
27
|
byte[] _key, _iv;
|
28
|
-
GenerateKeyFromPassWord(p,
|
28
|
+
GenerateKeyFromPassWord(p, _rijndael.KeySize, out _key, _rijndael.BlockSize, out _iv);
|
29
|
-
|
29
|
+
_rijndael.Key = _key;
|
30
|
-
|
30
|
+
_rijndael.IV = _iv;
|
31
31
|
|
32
32
|
|
33
33
|
|
34
|
-
System.Security.Cryptography.ICryptoTransform _decryptor =
|
34
|
+
System.Security.Cryptography.ICryptoTransform _decryptor = _rijndael.CreateDecryptor();
|
35
35
|
|
36
36
|
byte[] _strByte = System.Convert.FromBase64String(text);
|
37
37
|
|
@@ -57,7 +57,7 @@
|
|
57
57
|
}
|
58
58
|
```
|
59
59
|
|
60
|
-
復号プログラムは、"GenerateKeyFromPassWord"関数で、パスワードからkeyとivを作成し、
|
60
|
+
復号プログラムは、"GenerateKeyFromPassWord"関数で、パスワードからkeyとivを作成し、rijndaelのdecryptorでkey/ivを元に復号しているものと理解しています。
|
61
61
|
その逆(暗号化)を実現し、復号→編集→再暗号化→復号...と出来るようにしたいのですが、どうすればいいのかさっぱり見当がつきません。
|
62
62
|
|
63
63
|
非常におおざっぱな質問で大変恐縮に思っているのですが、ヒントだけでも頂けると幸いです...!
|