I have an encrypted string/Number in the database(which is done by SQL server encryption and looks like "䚶ઙᷤ阹熂" ),now i need to decrypt this through c# code.How can i achieve this? Can anyone help me on this?
-
1I think you should let the sql server decrypt the data again – JohnnBlade Jul 05 '12 at 06:40
-
You might wanna look here http://stackoverflow.com/questions/6491129/encrypt-in-sql-server-decrypt-in-net-4 – JohnnBlade Jul 05 '12 at 06:41
-
I am looking for a solution through c# code. – Bisileesh Jul 05 '12 at 06:50
-
the encryption of such kind is for the purpose of security and I guess it is made so that it cannot be decrypted. Unless or until you know the logic of encryption. I might be wrong as I am still a beginner at C#. – Ankit Suhail Jul 05 '12 at 07:00
-
In this scenario i am in need of decrypting it . I don't find any luck by googling.. – Bisileesh Jul 05 '12 at 07:14
-
@NewBornDeveloper can you provide a bit of more details. I mean what you are doing and what kind of string you are encrypting and how. – Ankit Suhail Jul 05 '12 at 07:21
-
@ankit suhail - I am using a trigger to encrypt the credit card details like Number,Type..etc, while storing it into DB.Now i need to decrypt this CC number and Type which i have encrypted.How can i do this? – Bisileesh Jul 05 '12 at 08:22
1 Answers
Do not store credit card information in a database. It's a recipe for trouble. Doing so will make you a very attractive target for hackers and, if they are successful in retrieving them, end your business and potentially ruin your life as well as the lives of those whose credit card numbers are stolen.
Also It is possible that storing such an information is illegal but depends upon the laws of you country. Please do check the guidelines.
If still you want to go ahead and do so and you want to store such an information then the just keep to the rule of ENCRYPT ENCRYPT ENCRYPT and never DECRYPT. Its like MD5 (i am not at all that you should just use algorithm like md5 for storing the credit card information) where you don't have an algorithm to decrypt but you can only encrypt the data. You can check the information entered matches the encryted data in the database by first encrypting the string with the same algorithm and then comparing it with the encrypted string in the database. Choose a good algorithm and a good and a secure server.
Be sure to choose an encryption algorithm that is secure and have not been broken yet.

- 2,045
- 21
- 32
-
I am doing it in a demo project for the sake of learning .NET and SQL. – Bisileesh Jul 05 '12 at 08:53
-
@NewBornDeveloper even i am a newbie.. learn it in a good way then.. their are million of programmers try to be a good programmer and not just a programmer. If you just want to learn about encrytion and descryption check out this thread http://stackoverflow.com/questions/202011/encrypt-decrypt-string-in-net – Ankit Suhail Jul 05 '12 at 08:58
-
I can understand that.I was trying to solve a problem which i faced during my coding.Anyway thanks for the information. – Bisileesh Jul 05 '12 at 09:02