Hi all,
When i try to decrypt my password which is stored in binary(16),null datatype in DB, it gives me error like 'Invalid length for a Base-64 char array.'.
i try the below code from one of the asp.net forum.
public string DecryptPassowrd(object obj)
{
string password = obj.ToString();
System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();
System.Text.Decoder utf8Decode = encoder.GetDecoder();
byte[] todecode_byte = Convert.FromBase64String(password);
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;
}
i got the error at byte[] todecode_byte = Convert.FromBase64String(password); line.
when i googled for that error many of site says to replace " " to "+".
byte[] todecode_byte = Convert.FromBase64String(password.Replace("","+"));
but when i did this it gives me another error.
String cannot be of zero length.
Parameter name: oldValue
so what sould i do to overcome this error?
thanks,
krunal