-
-
Notifications
You must be signed in to change notification settings - Fork 257
Description
Hi,
I maintain rust's base64 library, where a user reported a mismatch between cryptii's base64 decoding and rust's base64: marshallpierce/rust-base64#75.
The problem appears to be on cryptii's end: decoding iYW= results in 3 bytes, which is incorrect. 3 base64 chars map to 2 decoded bytes.
The decode loop incorrectly maps bits from the intermediate decode state to the output bytes. (It's also going to be quite slow with all those conditionals...)
I have to wonder, though -- why bother implementing base64 at all? The browser already provides it, or if you want to avoid the browser's implementation for some reason, you could delegate it to rust's base64 by compiling to WebAssembly (which last time I tested ended up being significantly faster than browsers' built in base64), or using any other WebAssembly-friendly C/Rust implementation.