File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Open Source Projects and the fly likes Very fast and small Base64 Codec project at Source Forge Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Very fast and small Base64 Codec project at Source Forge" Watch "Very fast and small Base64 Codec project at Source Forge" New topic
Author

Very fast and small Base64 Codec project at Source Forge

Mikael Grev
Greenhorn

Joined: Jul 15, 2004
Posts: 7
Hi,

I've just uploaded a project to Source Forge. It's a Base64 Codec.

"MiGBase64 is a very fast and small Base64 Codec written in Java. It is currently faster than any other Java codecs I know of and it doesn't create any temporary arrays which many others do. 3-30x faster than Sun's and 2x faster than Commons Codec"

It's under BSD licence, so feel free to use it!

MiGBase64

Cheers,
Mikael Grev
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Interesting. How did you actually get that kind of a performance boost compared to other implementations? And how are you avoiding the temporary arrays? By creating a big enough array in the beginning that you know won't need a resize?


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Mikael Grev
Greenhorn

Joined: Jul 15, 2004
Posts: 7
I couple of smart tricks ;-). Basically moving ALL but the absolute necessary out of the main loop.

Temp array: When encoding the array is possibly to precalculate, for decoding I have a normal and a "fast" varsion. Both are "fast" though. the normal do a pre-scan to know the exact returned length and the "fast" version has to be fed with data that are somewhat well behaved:

From Javadoc:

+ The array must have a line length of 76 chars OR no line separators at all (one line).
+ Line separator must be "\r\n", as specified in RFC 2045
+ The array must not contain illegal characters within the encoded string
+ The array CAN have illegal characters at the beginning and end, those will be dealt with appropriately.<br>

ps. You can check out the source, it's only some 50 lines per encode/decode pair.

Cheers,
Mikael
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Thanks.
Mikael Grev
Greenhorn

Joined: Jul 15, 2004
Posts: 7
Also a lot of performance charts is posted on the home page at:

http://migbase64.sourceforge.net/

Cheers,
Mikael
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Very fast and small Base64 Codec project at Source Forge
 
Similar Threads
If you need a fast base64 codec (ANN)
seeking your advice in choosing XML or RDBMS for Storing data
Sun equivalent to Apache Hex.encode/decode
How-to Pass Images using Web services?
[TUTORIAL] How to base64 encode decode Android