TripleDES 16 bytes not working

I am trying to port some projects from .net framework 4.5to .net core. The problem occurs when trying to transfer the old method crypting/decrypting. This method is TripleDESwith a key, which is an MD5 hash. An MD5 hash always returns 16 bytes. This works well in .net framework 4.5, but in .net corein System.Security.Cryptography.Algorithms TripleDESonly takes a KeySize of 24 bytes. In 4.5, it takes 16 bytes or 24 bytes. Are there any workarounds I could try?

Next, edit: The TripleDes class, upon initialization, calls the new TripleDesImplementation function, which this . And here it says that CNG does not support 128-bit keys.

+4
source share
1 answer

Unfortunately, there is no open source version of the TripleDes implementation that uses Framework 4.5.

However, assuming it matches the normal conventions for Triple DES , when it put two keys, it repeats the first key as the third key, you should be able to accept your existing 16-byte key and just repeat the first 8 bytes to form a 24- a byte key, and it should give the same results as you previously.

+7
source

Source: https://habr.com/ru/post/1651641/


All Articles