base64
encodes and decodes base64 as bytes or utf8
0.23.1
1.5B downloads/mo
#10 most downloaded on crates.io
marshallpierce/rust-base64
What this package is like to depend on
Last release 19 days ago
04 Aug 2026
Ships unpredictably
gaps range from 9 days to 2.2 years
Most releases are documented
notes for 34 of 41 stable releases
Nothing withdrawn
no release was ever pulled
11 years old
45 releases · first in 2015
2 releases in the last 12 months
see the full history below
Release timeline
45 releases · Dec 2015 to Aug 2026Releases
latest 45-
0.23.104 Aug 2026 -
0.23.023 Jul 2026Release notes
Open source →- Added more consts for preconfigured configs and engines
- Make DecodeError::InvalidLastSymbol more clear by including the decoded value
- Added SIMD-accelerated engines behind the default-on
simd-unsafefeature:Simdpicks the best instruction set at runtime (AVX2 onx86_64, NEON onaarch64) and falls back to the scalarGeneralPurposeengine, whileAvx2andNeontarget one instruction set with no runtime detection and work inno_std. The engines support the standard and URL-safe alphabets. - Update MSRV to 1.71.0
- Add support for custom padding symbols
-
0.22.130 Apr 2024 -
0.22.002 Mar 2024Release notes
Open source →DecodeSliceError::OutputSliceTooSmallis now conservative rather than precise. That is, the error will only occur if the decoded output cannot fit, meaning thatEngine::decode_slicecan now be used with exactly-sized output slices. As part of this,Engine::internal_decodenow returnsDecodeSliceErrorinstead ofDecodeError, but that is not expected to affect any external callers.DecodeError::InvalidLengthnow refers specifically to the number of valid symbols being invalid (i.e.len % 4 == 1), rather than just the number of input bytes. This avoids confusing scenarios when based on interpretation you could make a case for eitherInvalidLengthorInvalidBytebeing appropriate.- Decoding is somewhat faster (5-10%)
-
0.21.711 Jan 2024 -
0.21.608 Jan 2024 -
0.21.523 Oct 2023 -
0.21.410 Sep 2023Release notes
Open source →- Make
encoded_lenconst, allowing the creation of arrays sized to encode compile-time-known data lengths
- Make
-
0.21.326 Aug 2023Release notes
Open source →- Implement
sourceinstead ofcauseon Error types - Roll back MSRV to 1.48.0 so Debian can continue to live in a time warp
- Slightly faster chunked encoding for short inputs
- Decrease binary size
- Implement
-
0.21.225 May 2023Release notes
Open source →- Rollback MSRV to 1.57.0 -- only dev dependencies need 1.60, not the main code
-
0.21.122 May 2023Release notes
Open source →- Remove the possibility of panicking during decoded length calculations
DecoderReaderno longer sometimes erroneously ignores padding #226
Breaking changes
Engine.internal_decodereturn type changed- Update MSRV to 1.60.0
-
0.21.008 Jan 2023Release notes
Open source →Migration
Functions
< 0.20 function 0.21 equivalent encode()engine::general_purpose::STANDARD.encode()orprelude::BASE64_STANDARD.encode()encode_config()engine.encode()encode_config_buf()engine.encode_string()encode_config_slice()engine.encode_slice()decode()engine::general_purpose::STANDARD.decode()orprelude::BASE64_STANDARD.decode()decode_config()engine.decode()decode_config_buf()engine.decode_vec()decode_config_slice()engine.decode_slice()The short-lived 0.20 functions were the 0.13 functions with
configreplaced withengine.Padding
If applicable, use the preset engines
engine::STANDARD,engine::STANDARD_NO_PAD,engine::URL_SAFE, orengine::URL_SAFE_NO_PAD. TheNO_PADones require that padding is absent when decoding, and the others require that canonical padding is present .If you need the < 0.20 behavior that did not care about padding, or want to recreate < 0.20.0's predefined
Configs precisely, see the following table.0.13.1 Config 0.20.0+ alphabet encode_paddingdecode_padding_modeSTANDARD STANDARD true Indifferent STANDARD_NO_PAD STANDARD false Indifferent URL_SAFE URL_SAFE true Indifferent URL_SAFE_NO_PAD URL_SAFE false Indifferent -
0.21.0-rc.101 Jan 2023 pre-releaseRelease notes
Open source →- Restore the ability to decode into a slice of precisely the correct length with
Engine.decode_slice_unchecked. - Add
Engineas apub useinprelude.
- Restore the ability to decode into a slice of precisely the correct length with
-
0.21.0-beta.229 Dec 2022 pre-releaseRelease notes
Open source →Breaking changes
- Re-exports of preconfigured engines in
engineare removed in favor ofbase64::prelude::...that are better suited to those who wish tousethe entire path to a name.
- Re-exports of preconfigured engines in
-
0.21.0-beta.118 Dec 2022 pre-releaseRelease notes
Open source →Breaking changes
FastPortablewas only meant to be an interim name, and shouldn't have shipped in 0.20. It is nowGeneralPurposeto make its intended usage more clear.GeneralPurposeand its config are nowpub use'd in theenginemodule for convenience.- Change a few
from()functions to benew().from()causes confusing compiler errors because of confusion withFrom::from, and is a little misleading because some of those invocations are not very cheap as one would usually expect from afromcall. encode*anddecode*top level functions are now methods onEngine.DEFAULT_ENGINEwas replaced byengine::general_purpose::STANDARD- Predefined engine consts
engine::general_purpose::{STANDARD, STANDARD_NO_PAD, URL_SAFE, URL_SAFE_NO_PAD}- These are
pub used intoengineas well
- These are
- The
*_slicedecode/encode functions now return an error instead of panicking when the output slice is too small- As part of this, there isn't now a public way to decode into a slice exactly the size needed for inputs that aren't multiples of 4 tokens. If adding up to 2 bytes to always be a multiple of 3 bytes for the decode buffer is a problem, file an issue.
Other changes
decoded_len_estimate()is provided to make it easy to size decode buffers correctly.
-
0.20.010 Dec 2022Release notes
Open source →Breaking changes
- Update MSRV to 1.57.0
- Decoding can now either ignore padding, require correct padding, or require no padding. The default is to require
correct padding.
- The
NO_PADconfig now requires that padding be absent when decoding.
- The
0.20.0-alpha.1
Breaking changes
- Extended the
Configconcept into theEngineabstraction, allowing the user to pick different encoding / decoding implementations.- What was formerly the only algorithm is now the
FastPortableengine, so named because it's portable (works on any CPU) and relatively fast. - This opens the door to a portable constant-time
implementation (#153,
presumably
ConstantTimePortable?) for security-sensitive applications that need side-channel resistance, and CPU-specific SIMD implementations for more speed. - Standard base64 per the RFC is available via
DEFAULT_ENGINE. To use different alphabets or other settings ( padding, etc), create your own engine instance.
- What was formerly the only algorithm is now the
CharacterSetis nowAlphabet(per the RFC), and allows creating custom alphabets. The corresponding tables that were previously code-generated are now built dynamically.- Since there are already multiple breaking changes, various functions are renamed to be more consistent and discoverable.
- MSRV is now 1.47.0 to allow various things to use
const fn. DecoderReadernow owns its inner reader, and can expose it viainto_inner(). For symmetry,EncoderWritercan do the same with its writer.encoded_lenis now public so you can size encode buffers precisely.
-
0.20.0-alpha.114 Dec 2021 pre-releaseNothing published for this version
-
0.13.121 Oct 2022Release notes
Open source →- More precise decode buffer sizing, avoiding unnecessary allocation in
decode_config.
- More precise decode buffer sizing, avoiding unnecessary allocation in
-
0.13.030 Sep 2020Release notes
Open source →- Config methods are const
- Added
EncoderStringWriterto allow encoding directly to a String EncoderWriternow owns its delegate writer rather than keeping a reference to it (though refs still work)- As a consequence, it is now possible to extract the delegate writer from an
EncoderWriterviafinish(), which returnsResult<W>instead ofResult<()>. If you were callingfinish()explicitly, you will now need to uselet _ = foo.finish()instead of justfoo.finish()to avoid a warning about the unused value.
- As a consequence, it is now possible to extract the delegate writer from an
- When decoding input that has both an invalid length and an invalid symbol as the last byte,
InvalidBytewill be emitted instead ofInvalidLengthto make the problem more obvious.
-
0.12.325 Jun 2020Nothing published for this version
-
0.12.215 Jun 2020 -
0.12.106 May 2020 -
0.12.008 Mar 2020Release notes
Open source →- A
Readimplementation (DecoderReader) to let users transparently decoded data from a b64 input source - IMAP's modified b64 alphabet
- Relaxed type restrictions to just
AsRef<[ut8]>for mainencode*/decode*functions - A minor performance improvement in encoding
- A
-
0.11.025 Oct 2019Release notes
Open source →- Minimum rust version 1.34.0
no_stdis now supported via the two new featuresallocandstd.
-
0.10.125 Jan 2019Release notes
Open source →- Minimum rust version 1.27.2
- Fix bug in streaming encoding (#90): if the underlying writer
didn't write all the bytes given to it, the remaining bytes would not be retried later. See the docs
on
EncoderWriter::write. - Make it configurable whether or not to return an error when decoding detects excess trailing bits.
-
0.10.028 Oct 2018Release notes
Open source →- Remove line wrapping. Line wrapping was never a great conceptual fit in this library, and other features (streaming
encoding, etc) either couldn't support it or could support only special cases of it with a great increase in
complexity. Line wrapping has been pulled out into a line-wrap crate, so it's
still available if you need it.
Base64Displaycreation no longer uses aResultbecause it can't fail, which means its helper methods for common configs thatunwrap()for you are no longer needed
- Add a streaming encoder
Writeimpl to transparently base64 as you write. - Remove the remaining
unsafecode. - Remove whitespace stripping to simplify
no_stdsupport. No out of the box configs use it, and it's trivial to do yourself if needed:filter(|b| !b" \n\t\r\x0b\x0c".contains(b). - Detect invalid trailing symbols when decoding and return an error rather than silently ignoring them.
- Remove line wrapping. Line wrapping was never a great conceptual fit in this library, and other features (streaming
encoding, etc) either couldn't support it or could support only special cases of it with a great increase in
complexity. Line wrapping has been pulled out into a line-wrap crate, so it's
still available if you need it.
-
0.9.314 Sep 2018 -
0.9.231 May 2018 -
0.9.123 Apr 2018 -
0.9.019 Dec 2017Release notes
Open source →decode_config_slicefunction for no-allocation decoding, analogous toencode_config_slice- Decode performance optimization
-
0.8.017 Nov 2017 -
0.7.022 Sep 2017Release notes
Open source →STANDARD_NO_PADconfigBase64Displayheap-free wrapper for use in format strings, etc
-
0.6.010 Jun 2017Release notes
Open source →- Decode performance improvements
- Use
unsafein fewer places - Added fuzzers
-
0.5.203 May 2017Release notes
Open source →- Avoid usize overflow when calculating length
- Better line wrapping performance
-
0.5.130 Apr 2017 -
0.5.023 Apr 2017Release notes
Open source →- MIME support, including configurable line endings and line wrapping
- Removed
decode_ws - Renamed
Base64ErrortoDecodeError
-
0.4.203 May 2017Nothing published for this version
-
0.4.125 Mar 2017 -
0.4.012 Feb 2017 -
0.3.103 May 2017Nothing published for this version
-
0.3.017 Jan 2017Release notes
Open source →- Added encode/decode functions that do not allocate their own storage
- Decode performance improvements
- Extraneous padding bytes are no longer ignored. Now, an error will be returned.
-
0.2.120 Aug 2016Nothing published for this version
-
0.2.013 Jun 2016Nothing published for this version
-
0.1.104 Dec 2015Nothing published for this version
-
0.1.004 Dec 2015Nothing published for this version