Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm afraid that there is no "magic" function that will do this for both your server and the client. It is not hard to write a simple encryption / decryption scheme that will work across both though, since the algorithms are standard. Building your own will also help you to understand how the encryption and decryption works in your software.</p> <p>For .NET, you can use the System.Security.Cryptography namespace and for Win32 you should use the <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa380255%28v=vs.85%29.aspx" rel="nofollow">CryptoAPI</a>.</p> <p>As for the encryption scheme, going by your use case, you can use a simple symmetric encryption scheme.</p> <p>Encryption:</p> <ol> <li>Hash the user password together with a constant salt to create a 32-bit buffer. You can use SHA256 for this. The CryptoAPI SHA256 is only supported XP SP3 and up though. Otherwise you can find many open source implementations online.</li> <li>Take the first 16-bytes as the key and last 16 as the IV.</li> <li>Use the <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa386979%28v=vs.85%29.aspx" rel="nofollow">AES CryptoProvider</a> in the CryptoAPI to do the encryption using the key and the IV.</li> </ol> <p>Decryption:</p> <ol> <li>and 2. will be same as for encryption. .NET has built in classes for <a href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.sha256.aspx" rel="nofollow">SHA256</a> that you can use for this. Doing these steps should give you the same key as you have during encryption.</li> <li>Use the <a href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.aescryptoserviceprovider.aspx" rel="nofollow">AesCryptoServiceProvider</a> class to decrypt the data, using the key and the IV. See example here: <a href="https://gist.github.com/1833986" rel="nofollow">https://gist.github.com/1833986</a> (this one doesn't use any salt).</li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload