PulpCore

pulpcore.util
Class Base64

java.lang.Object
  extended by pulpcore.util.Base64

public class Base64
extends Object

Base64 encoding and decoding for network transport. This class follows the spec in RFC 4648.


Method Summary
static byte[] decode(String data)
          Decodes a Base64 string using the standard Base64 alphabet.
static byte[] decodeURLSafe(String data)
          Decodes a Base64 string using the URL-safe Base64 alphabet.
static String encode(byte[] data)
          Encodes binary data using the standard Base64 alphabet.
static String encode(byte[] data, boolean addPadding)
          Encodes binary data using the standard Base64 alphabet.
static String encodeURLSafe(byte[] data)
          Encodes binary data using the URL-safe Base64 alphabet.
static String encodeURLSafe(byte[] data, boolean addPadding)
          Encodes binary data using the URL-safe Base64 alphabet.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

encode

public static String encode(byte[] data)
Encodes binary data using the standard Base64 alphabet. The padding character ("=") is used.


encode

public static String encode(byte[] data,
                            boolean addPadding)
Encodes binary data using the standard Base64 alphabet. The padding character ("=") is optionally used.


decode

public static byte[] decode(String data)
Decodes a Base64 string using the standard Base64 alphabet. The padding character ("=") is not required.

Returns:
the decoded string, or null if data is null, or null if the string is not a Base64 string.

encodeURLSafe

public static String encodeURLSafe(byte[] data)
Encodes binary data using the URL-safe Base64 alphabet. The padding character ("=") is used.


encodeURLSafe

public static String encodeURLSafe(byte[] data,
                                   boolean addPadding)
Encodes binary data using the URL-safe Base64 alphabet. The padding character ("=") is optionally used.


decodeURLSafe

public static byte[] decodeURLSafe(String data)
Decodes a Base64 string using the URL-safe Base64 alphabet. The padding character ("=") is not required.

Returns:
the decoded string, or null if data is null, or null if the string is not a Base64 string.

PulpCore

Copyright © 2007-2009 Interactive Pulp, LLC.