I am trying to migrate some projects from .net framework 4.5
to .net core
.
The problem arrises when trying to migrate an old crypting/decrypting
method.
The method is a TripleDES
with a key that is a MD5 hash.
The MD5 hash always returns 16 bytes.
This works well in .net framework 4.5
, but in .net core
in System.Security.Cryptography.Algorithms
TripleDES
only accepts a KeySize of 24 bytes. In 4.5 it accepts 16 bytes or 24 bytes.
Are there any workarounds that i could try?
Later edit : The TripleDes class when initialized calls new TripleDesImplementation which is this . And here it is stated that the CNG does not support 128 bit keys.
Unfortunately, there's no open source version of the TripleDes implementation that is used by Framework 4.5.
However, assuming it's following normal conventions for Triple DES, that when it's supplied two keys it reuses the first key as the third key, you should be able to take your existing 16 byte key and just repeat the first 8 bytes to form a 24 byte key, and it should produce the same results as you previously obtained.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With