© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago
Alex

✅ Malformed input: 321 is an invalid input length

I'm working with Asp.Net Core Identity. I use
GeneratePasswordResetTokenAsync(user)
GeneratePasswordResetTokenAsync(user)
to generate token and encode it with
WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(token));
WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(token));
. Next I decode encoded token with
Encoding.UTF8.GetString(WebEncoders.Base64UrlDecode(encodedToken))
Encoding.UTF8.GetString(WebEncoders.Base64UrlDecode(encodedToken))
and get exception:
An unhandled exception occurred while processing the request.
FormatException: Malformed input: 321 is an invalid input length.
Microsoft.AspNetCore.WebUtilities.WebEncoders.GetNumBase64PaddingCharsToAddForDecode(int inputLength)
An unhandled exception occurred while processing the request.
FormatException: Malformed input: 321 is an invalid input length.
Microsoft.AspNetCore.WebUtilities.WebEncoders.GetNumBase64PaddingCharsToAddForDecode(int inputLength)

How can I fix my problem?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Invalid input in memu
C#CC# / help
4y ago
❔ Base64 invalid string error while the input is valid
C#CC# / help
3y ago
❔ Is there a way to name an object with an input?
C#CC# / help
3y ago
❔ Input into an int array
C#CC# / help
3y ago