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.

1 Like

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


I am running into the same issue after 6 years - you mentioned you created your own encode/decode methods for this reason - can you share them?

I am looking for the decode version and don’t like to make any mistake in the implementation