You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
staticbyte[]base64urldecode(stringarg){
string s=arg;s=s.Replace('-','+');// 62nd char of encodings=s.Replace('_','/');// 63rd char of encodingswitch(s.Length%4)// Pad with trailing '='s{case0: break;// No pad chars in this casecase2: s+="==";break;// Two pad charscase3: s+="=";break;// One pad chardefault: thrownewSystem.Exception("Illegal base64url string!");}returnConvert.FromBase64String(s);// Standard base64 decoder}
Can we have an option for byte-transforms/encode :base64 to include this padding?
The text was updated successfully, but these errors were encountered:
After looking through your code to prepare for writing a PR for this issue, I discovered that it is currently encoding in url-safe mode by default, which obviously disables the padding because "=" is reserved for query parameters. I wasn't expecting it to be enabled by default, because the simple example in your readme file explicitly passed the {:url-safe? true} option, indicating that url-safety was not the default behavior.
Updating the readme to indicate this behavior may be the best solution, because it would likely break too many people's code to switch the default behavior. However, I would normally expect options to be disabled by default. url-safe? sounds like a feature to be enabled, rather than a standard behavior to be disabled.
Yeah, this may have not been the best default, but I agree it's not something that can be easily changed at this point. I'll update the documentation to reflect this.
Many base64 decoding libraries expect the encoded string to be padded with one or two "=" characters so that the length is a multiple of 4, as given by the following sample code in https://tools.ietf.org/html/draft-ietf-jose-json-web-signature-08#appendix-C
Can we have an option for
byte-transforms/encode :base64
to include this padding?The text was updated successfully, but these errors were encountered: