bwLehrpool Masterserver
Manages authentication and sharing of virtual machines between participating institutions
Static Public Member Functions | Static Private Member Functions | Static Private Attributes | List of all members
org.openslx.imagemaster.util.Hash Class Reference
+ Collaboration diagram for org.openslx.imagemaster.util.Hash:

Static Public Member Functions

static String md5 (final byte[] bytes)
 Compute md5 hash of given binary data. More...
 
static String md5 (final String text)
 Compute md5 hash of the given string. More...
 
static String sha256 (final byte[] bytes)
 Compute sha256 hash of given binary data. More...
 
static String sha256 (final String text)
 Compute sha256 hash of the given string. More...
 

Static Private Member Functions

static String toHexString (final byte[] bytes)
 Convert given binary data to hex. More...
 

Static Private Attributes

static final ThreadLocal
< MessageDigest > 
md5hash
 Cache of md5 digesters. More...
 
static final ThreadLocal
< MessageDigest > 
sha256hash
 Cache of sha256 digesters. More...
 
static final char[] HEX_CHARS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }
 For converting to hex string. More...
 
static final Charset UTF8 = Charset.forName( "UTF-8" )
 Constant for the utf-8 charset, saves repeated lookups. More...
 

Detailed Description

Definition at line 7 of file Hash.java.

Member Function Documentation

static String org.openslx.imagemaster.util.Hash.md5 ( final byte[]  bytes)
static

Compute md5 hash of given binary data.

Parameters
bytesthe binary data in a byte array
Returns
hex representation of the 128bit md5 hash

Definition at line 60 of file Hash.java.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static String org.openslx.imagemaster.util.Hash.md5 ( final String  text)
static

Compute md5 hash of the given string.

The string will be converted to utf-8 before computation.

Parameters
textthe text to hash
Returns
hex representation of the 128bit md5 hash

Definition at line 72 of file Hash.java.

+ Here is the call graph for this function:

static String org.openslx.imagemaster.util.Hash.sha256 ( final byte[]  bytes)
static

Compute sha256 hash of given binary data.

Parameters
bytesthe binary data in a byte array
Returns
hex representation of the 256bit sha256 hash

Definition at line 85 of file Hash.java.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static String org.openslx.imagemaster.util.Hash.sha256 ( final String  text)
static

Compute sha256 hash of the given string.

The string will be converted to utf-8 before computation.

Parameters
textthe text to hash
Returns
hex representation of the 256bit sha256 hash

Definition at line 97 of file Hash.java.

+ Here is the call graph for this function:

static String org.openslx.imagemaster.util.Hash.toHexString ( final byte[]  bytes)
staticprivate

Convert given binary data to hex.

Parameters
bytesbinary data in a byte array
Returns
upper case hex representation of bytes

Definition at line 110 of file Hash.java.

+ Here is the caller graph for this function:

Member Data Documentation

final char [] org.openslx.imagemaster.util.Hash.HEX_CHARS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }
staticprivate

For converting to hex string.

Definition at line 46 of file Hash.java.

final ThreadLocal<MessageDigest> org.openslx.imagemaster.util.Hash.md5hash
staticprivate
Initial value:
= new ThreadLocal<MessageDigest>() {
@Override
public MessageDigest initialValue()
{
try {
return MessageDigest.getInstance( "MD5" );
} catch ( NoSuchAlgorithmException e ) {
e.printStackTrace();
System.exit( 1 );
return null;
}
}
}

Cache of md5 digesters.

Definition at line 12 of file Hash.java.

final ThreadLocal<MessageDigest> org.openslx.imagemaster.util.Hash.sha256hash
staticprivate
Initial value:
= new ThreadLocal<MessageDigest>() {
@Override
public MessageDigest initialValue()
{
try {
return MessageDigest.getInstance( "SHA-256" );
} catch ( NoSuchAlgorithmException e ) {
e.printStackTrace();
System.exit( 1 );
return null;
}
}
}

Cache of sha256 digesters.

Definition at line 29 of file Hash.java.

final Charset org.openslx.imagemaster.util.Hash.UTF8 = Charset.forName( "UTF-8" )
staticprivate

Constant for the utf-8 charset, saves repeated lookups.

Definition at line 50 of file Hash.java.


The documentation for this class was generated from the following file: