Aes.Key を secureString に変換するにはどうすればよいですか? byte[] -> string -> securestring を実行しています。私は別の問題に直面しています。キーをバイト[]で文字列に変換し、バイト[]に戻すと、別のバイト[]が得られます。コードの問題は何ですか?
Aes aes = Aes.Create();
aes.GenerateIV();
aes.GenerateKey();
byte[] byteKey1 = aes.Key;
string sKey = Encoding.UniCode.GetString(byteKey);
byte[] byteKey2= Encoding.UniCode.GetBytes(sKey);
「byteKey1」と「byteKey2」が異なる場合があります。Encoding.Default を使用する場合は同じですが、マシンごとにデフォルトのエンコーディングが異なる場合に問題が発生します。
byte[] の Key を SecureString に変換し、 byte[] に戻すにはどうすればよいですか?
ありがとう。