Support for urlsafe alphabets in Base64?



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


or the generic case

base64decode(str, alphabet=myAlphabet)


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


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