.net - Why does set key not do anything in AES/SymmetricAlgorithm? -


This gives me a hard answer, I thought I was setting the key but I was not. There is no exception, nothing happens except bad results, if everything is ignored, then why is there a setter and no exception can be thrown on trying to write? What does the Setter on Key Property mean?

When I am down, the basic value is not changed. After an hour when I know what's going on, I've been writing a loop to verify. I also tried AES Of [0] = val; Var b = val == aes.Key [0]; (And mess with it in urgent mode).

Why is this behavior this?

  Array.Copy (myKey, aes.Key, aes.Key.Length); Int i = 0; Fortes (var v in aes.Key) {var b = myKey [i ++] == V; If (! B) B = B; }  

Well, for one thing, you are not using setter. What you're doing is using gates (which captures a copy key), and setting the key array in the setting of individual bytes (which do not affect the internal state AesCryptoServiceProvider ).

If you want the setter to work correctly, then create a new byte array and set the property:

  byte [ ] NewKey = new byte [aids. Casey's / 8]; // Generate your key ... aes.Key = newKey;  

Feedback to the comment:

Your example is in fully managed code and you can clearly specify the byte array DummyArray Naturally you can choose any index, because you have chosen to reverse the reference. However, there is no need to re-reference the byte array reference (this is the implementation details).

Managed CSPs are just wrapping calls to unmanaged, so when the data is pressed, whatever you are receiving is a copy of the actual data.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -