tags:

views:

249

answers:

4

Hii, I had a requirement of encode a string provided to a unreadable format and also have to decode after certain action performed. I have tried 'Base64' encoding. But this is not a secure way. I need some other solutions. Give some help regarding the above context.

+2  A: 

You could use a symmetric encryption algorithm. Here's an example. Both sides (encrypt/decrypt) must share a common secret key for this to work.

Darin Dimitrov
+1  A: 

You're looking for symmetric encryption. There are several libraries in C# available. You could use RijndaelManaged for example. See this SQ question for an example

edosoft
+1  A: 

See following
http://www.codeproject.com/KB/cs/Cryptography.aspx
http://www.codeproject.com/KB/security/DotNetCrypto.aspx

Here is an example using RSA. Replace your_rsa_key with your RSA key.

System.Security.Cryptography.RSACryptoServiceProvider Provider =
                new System.Security.Cryptography.RSACryptoServiceProvider();
Provider.ImportParameters(your_rsa_key);
byte[] encrypted = Provider.Encrypt(System.Text.Encoding.UTF8.GetBytes("Hello World!"), true);
string decrypted = System.Text.Encoding.UTF8.GetString(Provider.Decrypt(encrypted, true));
Brij
+1  A: 

The System.Security.Cryptography namespace can help you. But when choosing your encryption algorithm take in mind the size of data you are trying to encrypt and the level of security you want to achieve.

Fahad