at.knowcenter.wag.egov.egiz.tools
Class CodingHelper

java.lang.Object
  extended by at.knowcenter.wag.egov.egiz.tools.CodingHelper

public class CodingHelper
extends Object

This class provides encoding and decoding methods and other coding methods. All methods are static!

Author:
wlackner

Constructor Summary
CodingHelper()
           
 
Method Summary
static byte[] buildDigest(byte[] data)
          This method builds an SHA-1 hash value of a given byte array.
static byte[] decodeBase64(byte[] ba)
          This method decodes a given Base64 byte array
static byte[] decodeBase64(String theString)
          This method decodes a given Base64 string.
static String decodeUTF8FromBase64(String encoded_string)
          This method decodes the UTF-8 bytes from a Base64 US-ASCII (Java) String and decodes the UTF-8 bytes to a unicode (Java) String.
static String encodeBase64(byte[] plainString)
          This method encodes a given byte array Base64
static String encodeUTF8AsBase64(String plain_string)
          This method encodes a given Unicode (Java) String to UTF-8 bytes and then encodes these UTF-8 bytes to a Base64 US-ASCII (Java) String.
static String htmlEscape(String rawString)
          This method escapes a given string with HTML entities.
static boolean isB64(byte[] byteArray)
          This method checks, if a byte array contains chars that are not base64 conform.
static boolean isB64(String string)
          This method checks, if a string contains chars that are not base64 conform.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CodingHelper

public CodingHelper()
Method Detail

encodeUTF8AsBase64

public static String encodeUTF8AsBase64(String plain_string)
This method encodes a given Unicode (Java) String to UTF-8 bytes and then encodes these UTF-8 bytes to a Base64 US-ASCII (Java) String.

Parameters:
plain_string - to be encoded
Returns:
the UTF-8 and Base64 encoded string

decodeUTF8FromBase64

public static String decodeUTF8FromBase64(String encoded_string)
This method decodes the UTF-8 bytes from a Base64 US-ASCII (Java) String and decodes the UTF-8 bytes to a unicode (Java) String.

Parameters:
encoded_string - to be decoded
Returns:
the Base64 and UTF-8 decoded string

decodeBase64

public static byte[] decodeBase64(String theString)
This method decodes a given Base64 string.

Note that the given String must only contain Base64 characters. (The string will be converted to a byte array of "US-ASCII" (7 bit) bytes and then this byte array will be decoded using the Base64 algorithm.

Parameters:
theString - to be decoded
Returns:
a Base64 decoded byte array

decodeBase64

public static byte[] decodeBase64(byte[] ba)
This method decodes a given Base64 byte array

Parameters:
ba - the byte array to be decoded
Returns:
a Base64 decoded byte array

encodeBase64

public static String encodeBase64(byte[] plainString)
This method encodes a given byte array Base64

Parameters:
plainString - the byte array to be encoded
Returns:
the Base64 encoded string

buildDigest

public static byte[] buildDigest(byte[] data)
This method builds an SHA-1 hash value of a given byte array.

Parameters:
data - the byte array to build the hash value for
Returns:
the calculated hash value as a byte array
See Also:
MessageDigest

htmlEscape

public static String htmlEscape(String rawString)
This method escapes a given string with HTML entities.

Parameters:
rawString - the string to escaped
Returns:
the HTML escaped string

isB64

public static boolean isB64(byte[] byteArray)
This method checks, if a byte array contains chars that are not base64 conform.

Parameters:
byteArray - the array to test
Returns:
boolean, if a byte array is base64 conform, false otherwise

isB64

public static boolean isB64(String string)
This method checks, if a string contains chars that are not base64 conform.

Parameters:
string - the chars to test
Returns:
boolean, if the given string is base64 conform, false otherwise


Copyright © 2006-2007 EGIZ - E-Government Innovationszentrum. All Rights Reserved.