org.owasp.webscarab.util
Class Encoding

java.lang.Object
  extended by org.owasp.webscarab.util.Encoding

public final class Encoding
extends java.lang.Object

Utilities to (de-)code data.

Since:
0.1
Version:
0.2rc
CVS $Revision: 1.4 $ $Author: rogan $
Author:
ingo@ingostruck.de

Method Summary
static byte[] base64decode(java.lang.String coded)
          Decodes a Base64 encoded String.
static java.lang.String base64encode(byte[] code)
          Encodes a byte array to a Base64 encoded String.
static java.lang.String hashMD5(byte[] bytes)
           
static java.lang.String hashMD5(java.lang.String str)
          Returns the MD5 hash of a String.
static java.lang.String hashSHA(java.lang.String str)
          Returns the SHA hash of a String.
static java.lang.String rot13(java.lang.String input)
          Description of the Method
static java.lang.String toHexString(byte[] b)
          Converts a byte array into a hexadecimal String.
static java.lang.String urlDecode(java.lang.String str)
          Description of the Method
static java.lang.String urlEncode(java.lang.String str)
          Description of the Method
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

base64encode

public static java.lang.String base64encode(byte[] code)
Encodes a byte array to a Base64 encoded String.
(cf. RFC 1341 section 5.2) This implementation heavily outperforms sun.misc.BASE64Encoder, which is not "officially" available anyway (about four times faster on 1.3 and about double speed on 1.4).

Parameters:
code - the byte code to be encoded
Returns:
the Base64 encoded String representing the plain bytecode

base64decode

public static byte[] base64decode(java.lang.String coded)
Decodes a Base64 encoded String.
(cf. RFC 1341 section 5.2) NOTE: This decoder silently ignores all legal line breaks in the input and throws a RuntimeException on any illegal input. This impl slightly outperforms sun's decoder on 1.3 and heavily outperforms it on 1.4 (about a third faster).

Parameters:
coded - the string to be decoded
Returns:
the plain bytecode represented by the Base64 encoded String

toHexString

public static java.lang.String toHexString(byte[] b)
Converts a byte array into a hexadecimal String.

Parameters:
b - a byte array to be converted
Returns:
a hexadecimal (lower-case-based) String representation of the byte array

hashMD5

public static java.lang.String hashMD5(java.lang.String str)
Returns the MD5 hash of a String.

Parameters:
str - Description of the Parameter
Returns:
Description of the Return Value

hashMD5

public static java.lang.String hashMD5(byte[] bytes)

hashSHA

public static java.lang.String hashSHA(java.lang.String str)
Returns the SHA hash of a String.

Parameters:
str - Description of the Parameter
Returns:
Description of the Return Value

rot13

public static java.lang.String rot13(java.lang.String input)
Description of the Method

Parameters:
input - Description of the Parameter
Returns:
Description of the Return Value

urlDecode

public static java.lang.String urlDecode(java.lang.String str)
Description of the Method

Parameters:
str - Description of the Parameter
Returns:
Description of the Return Value

urlEncode

public static java.lang.String urlEncode(java.lang.String str)
Description of the Method

Parameters:
str - Description of the Parameter
Returns:
Description of the Return Value