geel9 / SteamAuth

A C# library that provides vital Steam Mobile Authenticator functionality
MIT License
276 stars 102 forks source link

[FIXED] SharedSecret with Backslash "\" issue. SteamGuardAccount.cs fails due to the char is not a valid base64 #57

Closed speed-str closed 8 years ago

speed-str commented 8 years ago

While the program works great with most shared secrets, i found one particular problem when using a shared secret having "\" Backslash in it. The program throws exception at line byte[] sharedSecretArray = Convert.FromBase64String(this.SharedSecret); Because the character "\" is not a valid base64 and hence it cannot be converted. Any idea on how to achieve it ?

shravan2x commented 8 years ago

Escape characters sometimes get added to the secrets. Just replace it with the escaped value and you should be fine.

speed-str commented 8 years ago

@Shravan2x sorry if i sound like a complete noob but i've tried replacing the backslash and it still doesn't work. i found on the internet that replace wont work on the backslash. I've been trying this:

string text = Console.ReadLine(); text.Replace("\", ""); text.Replace("\"", "");

shravan2x commented 8 years ago

You're replacing it with nothing. That's not what you need to do. You need to escape the escape character.

BlueRaja commented 8 years ago

It sounds like the string needs to be run through Regex.Unescape

speed-str commented 8 years ago

@BlueRaja Sweet ! i used that method and it worked like a charm, here is what i was doing

string SharedSecretUnescaped = Regex.Unescape(SharedSecretEscaped); byte[] sharedSecretArray = Convert.FromBase64String(SharedSecretUnescaped);

Should we create a pull request ?

BlueRaja commented 8 years ago

A PR would make sense, yeah

speed-str commented 8 years ago

PR created