Click here to Skip to main content
15,886,724 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone, At this moment I have an application that encrypts some value using a function created on SQL SERVER and this function returns the encrypted value to the user, when the user made click on some button I need to decrypt the encrypted value using a SQL SERVER function, but I dont know how to do that, any recommendations
Posted

Just one quesrtion: why on Earth? What's this good for? Why doing two roundrips for nothing? There is absolutely no use enctrypting values with symmetric encryption in a web application. Use https and encrypt the traffic, or forget it. Why? Because you neet to send the key also. And at that point the whole encryption is useless.
On the other hand, if you send encrypted data to the client, than you send it beack to the server just to decrypt it, and to send it back unencrypted... well, I prefere not to make any statement about this scenario.

But let's suppose for a second, that for some reason this obscrubtion (as it is not cryptography, just because you use a cryptographic function) is useful. You wrote, that on server side the sql server is encrypting the data with AES (I would never put such a functionality in the datastore tier), and you send this chipertext to the client via an asp.net application. Than you have have a client with a browser where you have javascript also. So why don't you decrypt in javascript? AES is just AES. Just use this for example: https://code.google.com/p/crypto-js/[^]
 
Share this answer
 
v3
Comments
abrchaves 5-Dec-14 16:15pm    
Ok, I am going to explain what I need. I have a customer that needs to run a daily process to manage all the documents related with his business (purchase document, sales document, receivables document, etc.). This process is going to be executed through stored procedure only when two parameters "hours to" and "hours from" are valid.

These values "hours to" and "hours from" are stored on a table in the database, and these values came encrypted from an application builded in .NET, why? because the client needs to set the values for these parameters and the client wants all the encrypted values are generated from SQL SERVER, for this reason I have a textbox to set some value for "hours to", I am going to encrypt this values and later I need to desencrypt on SQL SERVER.

An example:
"AO2nf95cBLHF6wpbzBOWdQEAAABkVPYo/6l+EMROSQ8KVhMYv8xQbEnZYLEzHFnuMrxo4Q=="
Zoltán Zörgő 5-Dec-14 16:24pm    
But why are these date values stored in the database in encrypted form? This does not look as something that needs to be stored only encrypted. You should decrypt them before you store them. Or at least store them both encrypted and unencrypted.
My recommendation:
Encrypt and decrypt it in C#, not in SQL Server.
Using something like this:
C# AES 256 bits Encryption Library with Salt[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900