0

According to Microsoft's documentation on System.Security.Cryptography.Aes, the key size can simply be changed by setting the KeySize property.

Does changing the key size automatically generate a new random key of the new key size? The documentation is not clear.

Old Geezer
  • 14,854
  • 31
  • 111
  • 198

1 Answers1

0

Yes, or no, depending.

Setting KeySize makes the object forget the key. If a new one is provided by setting Key no new key was technically generated. But when the object has no key, but needs one, a new key (of size KeySize) is created and remembered.

In general, you should either set KeySize (to make a random one) or Key (which adjusts KeySizeValue), not both.

bartonjs
  • 30,352
  • 2
  • 71
  • 111