Fast Base64 Encoder

Boost your application today!

This library provides a pure java encoder for the Base64 algorithm with support for arrays, buffers, streams and channels. According to our benchmark, this is simply the fastest encoder. It is ten times faster then Sun internal encoder and twice faster than Apache Jakarta's one on big arrays of byte. The gain is even higher when working with small arrays.

Benchmark

It was conducted on Linux with Sun JRE 1.4.2_03 and Sun JRE 1.5.0beta2 in server mode. It included the following encoders:

  • sun.misc.BASE64Encoder (internal, versions 1.4 and 1.5)
  • Apache Jakarta Commons Codec Base64 Encoder (version 1.3)
  • ByteCream Fast Base64 Encoder (version 1.0)

Size of the
byte array
Gain over
Sun
Gain over
Jakarta
0b-1K+17036%+134%
1K-100K+1157%+122%
100K-1M+894%+101%
1M-10M+697%+72%
10M-50M+829%+83%

Requirements

This library requires java 1.4 (or later). Contact us if you need it for java 1.3.

Documents

You can read the following documents:

Pricing

Prices are decreasing quickly with the quantity. The development license includes illimited email support for six months and new major and minor releases for ever. Please contact us with your requirements.

Summer Price: 20% off 'til 2007-09-05

Examples Price New Price
1 development license (one by developper)
also includes 5 deployment licenses
50.00 USD 40.00 USD
5 development licenses (one by developper)
also includes 25 deployment licenses
100.00 USD 80.00 USD
(16.00$/u)
20 development licenses (one by developper)
also includes 100 deployment licenses
165.00 USD 138.00 USD
(6.90$/u)
50 deployment licenses (one by CPU)
 
45.60 USD 38.00 USD
(0.76$/u)
10000 deployment licenses (one by CPU)
 
840.00 USD 700.00 USD
(0.07$/u)

Adapters

We recommand to use directly our API. But if you can not change your application, we provide six adapters for:

  • Apache Axis Utils Base64 1.1: view the API, download the archive
  • Apache Jakarta Commons Codec Base64 1.3: view the API, download the archive
  • Apache Tomcat 5: view the API, download the archive
  • Apache Xerces 2: view the API, download the archive
  • Sun internal Apache Xerces: view the API, download the archive
  • Sun internal BASE64Encoder 1.4: view the API, download the archive

These adapters are free of charge but also come without warranty and support.

 Benchmark

 Tips for upgrading your code: encoding a byte array

  • To replace
      new sun.misc.BASE64Encoder().encode(_data),
    use
      Base64Encoder.encodeWithLineSeparator
        (data,(data.length%57==0))
    .

    The second agrument is needed due to the strange behavior of BASE64Encoder: a line separator is added to the final line only if this line has 76 characters.

  • To replace
      org.apache.commons.codec.binary.Base64.encode(data),
    use
      Base64Encoder.encodeWithCRLF(data,true).


 Example: encoding a file

(this code has been kept short for clarity)

import java.io.*;
import java.nio.channels.*;
import com.bytecream.codec.*;

public final class Encode64 {
  public static void main(String[] args)
    throws IOException {
    RandomAccessFile in  =new RandomAccessFile(args[0],"r");
    RandomAccessFile out =new RandomAccessFile(args[1],"rw");
    FileChannel      cin =in .getChannel();
    FileChannel      cout=out.getChannel();

    Base64EncoderNIO.encodeWithCRLF(cin,cout);

    cin .close();
    in  .close();
    cout.close();
    out .close();
  }
}