Click here to Skip to main content
15,919,434 members
Please Sign up or sign in to vote.
2.33/5 (3 votes)
See more:
hi all,

I wanna very good encryption and decryption algorithm in c#?.

I googled Some page,.. I got one,..

private string base64Encode(string sData)
          {
              try
              {
                  byte[] encData_byte = new byte[sData.Length];
                  encData_byte = System.Text.Encoding.UTF8.GetBytes(sData);
                  string encodedData = Convert.ToBase64String(encData_byte);
                  return encodedData;
              }
              catch (Exception ex)
              {
                  throw new Exception("Error in base64Encode" + ex.Message);
              }
          }


public string base64Decode(string sData)
           {
               System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();
               System.Text.Decoder utf8Decode = encoder.GetDecoder();
               byte[] todecode_byte = Convert.FromBase64String(sData);
               int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
               char[] decoded_char = new char[charCount];
               utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);
               string result = new String(decoded_char);
               return result;
           }


Is it good?. else suggest a good one.


and What is the different between encode and encription?

thanks in advance!.
Posted
Comments
Vivek Krishnamurthy 2-Jun-11 8:27am    
I see 2 question here. First one in the header that is very well answered by John S.

will get to second part.Very good encryption and decryption algorithim in c#
This really depneds on your need. Can you please eloborate what you are looking for ?
Sergey Alexandrovich Kryukov 2-Jun-11 16:54pm    
I would deny answering most of the questions in the form "what is the difference between {0} and {1}" -- completely. In general case it's logically non-computable. "What is the difference apple and Apple?" :-) We should not encourage such lame things. No matter how good is the expert it puts her/him in awkward position. Not worth answering. I'll report it as not a question.
--SA

 
Share this answer
 
Comments
Sagotharan Jagadeeswaran 3-Jun-11 0:51am    
my 5!
Encoding is NOT encryption:

http://www.di-mgt.com.au/encode_encrypt.html[^]
 
Share this answer
 
Comments
Sagotharan Jagadeeswaran 2-Jun-11 7:51am    
ok. any suggestion of a good one.
Guyverthree 2-Jun-11 11:51am    
Indeed I agree.

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