Click here to Skip to main content
14,981,861 members
Please Sign up or sign in to vote.
1.82/5 (3 votes)
See more:
This is the my decoding method:

C#
public static string DecodeFrom64(string m_enc)
   {
       byte[] encodedDataAsBytes =
       System.Convert.FromBase64String(m_enc);
       string returnValue =
       System.Text.Encoding.UTF8.GetString(encodedDataAsBytes);
       return returnValue;
   }


The error is:
The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or a non-white space character among the padding characters.


Why i am getting this error any one pls help me...
Posted
Updated 20-Jun-17 20:01pm

1 solution

The error message is pretty specific: "as it contains a non-base 64 character, more than two padding characters, or a non-white space character among the padding characters"

So, I would guess that you either haven't converted your string to Base 64 correctly, or you have corrupted it since. Without knowing more about you application, we can't say much more.

Look at the string when you have first converted it. Does it look like the one you are trying to convert back? If not, how not? And Why not?

BTW: You do realize that Base64 is not an encryption system? That if you are trying to use it as such, it is about as secure as writing "DO NOT READ" on the outside of your personal diary?
   
Comments
shwetha1 26-May-12 5:50am
   
Thanks for u r reply...
Is there any another approach to decode my password..
OriginalGriff 26-May-12 5:54am
   
Password? Oh dear, oh dear.
Base 64 is not a secure system, in any way shape, or form.
You should not encrypt passwords anyway! Hash them instead.
There is some information on how to do it here:
http://www.codeproject.com/Tips/186585/Password-Storage-How-to-do-it.aspx
shwetha1 26-May-12 6:43am
   
Thank you for sharing this link..
But i have problem i can't understand how to convert this code to as my requirement but it gives an idea to me...
Anyho thanks again..

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