using System.Security.Cryptography;
private string Encrypt(string clearText)
{
string strmsg = string.Empty;
byte[] encode = new byte[clearText.Length];
encode = Encoding.UTF8.GetBytes(clearText);
strmsg = Convert.ToBase64String(encode);
return strmsg;
}
private string Decrypt(string cipherText)
{
string decryptpwd = string.Empty;
UTF8Encoding encodepwd = new UTF8Encoding();
Decoder Decode = encodepwd.GetDecoder();
byte[] todecode_byte = Convert.FromBase64String(cipherText);
int charCount = Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
char[] decoded_char = new char[charCount];
Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);
decryptpwd = new String(decoded_char);
return decryptpwd;
}
private string Encrypt(string clearText)
{
string strmsg = string.Empty;
byte[] encode = new byte[clearText.Length];
encode = Encoding.UTF8.GetBytes(clearText);
strmsg = Convert.ToBase64String(encode);
return strmsg;
}
private string Decrypt(string cipherText)
{
string decryptpwd = string.Empty;
UTF8Encoding encodepwd = new UTF8Encoding();
Decoder Decode = encodepwd.GetDecoder();
byte[] todecode_byte = Convert.FromBase64String(cipherText);
int charCount = Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
char[] decoded_char = new char[charCount];
Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);
decryptpwd = new String(decoded_char);
return decryptpwd;
}
No comments:
Post a Comment