0

I need to decrypt/encrypt based on the machine key. How can we generate the key and IV values? Is there any tool to do like this?

I am using .NET Framework 3.5

To tell what is required Ex:

//24 byte or 192 bit key and IV for AES
private static byte[] KEY_192 = { ... };
private static byte[] IV_192 = { ... };
4

1 に答える 1

2

FormAuthenticationクラスを活用することで技術的にこれをハッキングできると思います。内部で同じ暗号化を使用します。

var dataTicket = new FormsAuthenticationTicket(1, String.Empty, DateTime.UtcNow, DateTime.UtcNow.AddDays(1), true, "encrypt me!");
var encryptedData = FormsAuthentication.Encrypt(dataTicket);
...
dataTicket = FormsAuthentication.Decrypt(encryptedData);
Console.WriteLine(dataTicket.UserData); // "encrypt me!"

より良い解決策は、.NET 4 にアップグレードしてMachineKeyクラスを直接使用することです。

于 2013-01-07T14:49:07.003 に答える