Wednesday, 26 August 2015

Insert the data/password by using Cryptography (Encryption/Decryption)


  • Always store password using reversible encryption so as the encrypted password can also be decrypted when need to be used.
  • But at the same time it is also important to use the strong encryption algorithm.
  • Here I'll demonstrate you one of the method for encrypting the data and storing them into database. And Vice-versa.

  • Two Class file one is DBAccess where all database stuffs are done and another EncDecClass file for encrypting and decrypting the data.


  • This code shows the button click event for storing the encrypted password into database. It calls "Encrypt" method of Class file for encrypting the password.

  • Before encryption you should generate a key which is as shown below.


  • Now let us see how Encrypt method works:
  • And in the same way for decryption. We'll call decrypt method from codebehind file for decryption of password .
  • This code shows the button click event for retrieving the encrypted password into database. It calls "Decrypt" method of Class file for decrypting  the password.

  • Now let use see how the decryption works.


  • And yes this is it.  Here your password get decrypted.
  • For more information leave comments please.
  • And let me know the difficulties you are facing I'll definitely try to sort it out if I had gone through it.
  • Good Luck!

No comments:

Post a Comment

How To Pass An Array As A Parameter While Calling an ASP.NET Web API C#

Please visit my C# Corner Blog for this, where I have provided better efforts to make this concept more understandable - www.c-sharpcorner....