Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RijndaelManaged encrypt replacement of Enterprise Library

I have a question regarding the encryption: basically in my web application I've used Enterprise Library 5.0 where they had a block for cryptography, so basically in the configuration tool provided by them I've registered a block and generated a key. This basically adds few lines in the web config, so that later in web application i can do the following:

Cryptographer.EncryptSymmetric("RijndaelManaged", text);
Cryptographer.DecryptSymmetric("RijndaelManaged", text);

This would automatically encrypt and decrypt correctly, withouth any issues.

Now I've a following problem, we are moving from Enterprise Library 5.0 to Enterprise Library 6.0 and in the new version they've removed the Cryptography block and instead they advise to use .Net cryptography.

So instead I decided to use Rijndael .Net class to replace this lines with custom code. I've used this topic as a reference (Encrypt and decrypt a string) but with RijndaelManaged to create it, but i'm a bit confused, how about the key ... because some data is already encrypted how to get and use the same key to be able to decrypt the data and use it ...?

I opened the configuration manager of the version 5.0 to see the key but can i use it or not?

Can anyone elaborate me on this one?

like image 426
Alnedru Avatar asked Dec 12 '14 10:12

Alnedru


1 Answers

how to get and use the same key to be able to decrypt the data and use it ...?

One of the idea of crypto cyphers is that they are independent of the implementing technology. You can encrypt data with .NET and decrypt it with Java or whatever. All you need to do can be summarised as:

  • Have the key. In symmetric crypto, the same key is used for both encryption and decryption processes
  • Have configuration values (such as IV or initialisation vector, length of the cypher block, type of the encryption, hash function used, name of the cypher, etc)

Given you have those two, you can encrypt/decrypt in any technology (with a bit of pain to get it going first, mostly spent searching for correct key or configuration)

I opened the configuration manager of the version 5.0 to see the key but can i use it or not?

Not familiar with config manager, but you must extract the key from somewhere. Be sure to get it in the right format - you need raw binary format. If it is saved in a file, it could be encrypted with say Windows DP API, or could be stored in Base64 format.

like image 126
oleksii Avatar answered Sep 19 '22 07:09

oleksii