Support for urlsafe alphabets in Base64?

question

#1

the Base64 module seems to be hardcoded to use the standard alphabet - I need to consume data encoded with the urlsafe alphabet (-,_ instead of +,/). As a workaround I’m translating the source string into the urlsafe equivalent before decoding, like

base64decode(replace(replace(str, "-", "+"), "_", "/"))

but this feels pretty dirty, and obviously impractical for arbitrary alphabets. I think there’s value in separating the base64 encoding/decoding routines from the alphabet they use, allowing convenience functions

urlsafebase64decode(str)

or the generic case

base64decode(str, alphabet=myAlphabet)

#2

I ended up writing my own base64 encode/decode methods, for this exact reason.


#3

You could make a PR allowing different alphabets to be specified.