Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...Regarding Encryption Key in HostSettings TableRegarding Encryption Key in HostSettings Table
Previous
 
Next
New Post
4/3/2007 1:56 PM
 
Hi all,

I'm using DNN 2.1 and till now I wasnt encrypting my passwords but now I want to so I just changed the value of the "Encryption Key" column in the "HostSettings" table to RSA. But how do I modify my code such that I can send in encrypted passwords to my SQL server. I tried an algo for RSA which went like this -

static byte[] Encrypt (RSA rsa, byte[] input) 
{
     // by default this will create a 128 bits AES (Rijndael) object
     SymmetricAlgorithm sa = SymmetricAlgorithm.Create ();
     ICryptoTransform ct = sa.CreateEncryptor ();
     byte[] encrypt = ct.TransformFinalBlock (input, 0, input.Length);

     RSAPKCS1KeyExchangeFormatter fmt = new RSAPKCS1KeyExchangeFormatter (rsa);
     byte[] keyex = fmt.CreateKeyExchange (sa.Key);

     // return the key exchange, the IV (public) and encrypted data
     byte[] result = new byte [keyex.Length + sa.IV.Length + encrypt.Length];
     Buffer.BlockCopy (keyex, 0, result, 0, keyex.Length);
     Buffer.BlockCopy (sa.IV, 0, result, keyex.Length, sa.IV.Length);
     Buffer.BlockCopy (encrypt, 0, result, keyex.Length + sa.IV.Length, encrypt.Length);
     return result;
}

static byte[] Decrypt (RSA rsa, byte[] input) 
{
     // by default this will create a 128 bits AES (Rijndael) object
     SymmetricAlgorithm sa = SymmetricAlgorithm.Create ();

     byte[] keyex = new byte [rsa.KeySize >> 3];
     Buffer.BlockCopy (input, 0, keyex, 0, keyex.Length);

     RSAPKCS1KeyExchangeDeformatter def = new RSAPKCS1KeyExchangeDeformatter (rsa);
     byte[] key = def.DecryptKeyExchange (keyex);

     byte[] iv = new byte [sa.IV.Length];
     Buffer.BlockCopy (input, keyex.Length, iv, 0, iv.Length);

     ICryptoTransform ct = sa.CreateDecryptor (key, iv);
     byte[] decrypt = ct.TransformFinalBlock (input, keyex.Length + iv.Length, input.Length - (keyex.Length + iv.Length));
     return decrypt;
}

Please guide me regarding this. Any other 2 -way encryption also welcome..

Thanks,
Sanchita
 
Previous
 
Next
HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...Regarding Encryption Key in HostSettings TableRegarding Encryption Key in HostSettings Table


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out