org.openptk.util
Class Digest

java.lang.Object
  extended by org.openptk.util.Digest

public class Digest
extends java.lang.Object

Generates a digest (SHA) from a String or byte[].

Author:
Scott Fehrman, Sun Microsystems, Inc.

Field Summary
static java.lang.String ALGORITHM_DEFAULT
           
static java.lang.String[] ALGORITHM_PREFIXS
           
static java.lang.String ALGORITHM_SHA
           
 
Method Summary
static java.lang.String generate(byte[] bytes)
          Generate a digest (String) from the byte[].
static java.lang.String generate(java.lang.String str)
          Generate a digest (String) from the String.
static boolean isHashed(java.lang.String str)
           
static void main(java.lang.String[] args)
           
static boolean validate(java.lang.String hashed, byte[] bytes)
           
static boolean validate(java.lang.String hashed, java.lang.String str)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALGORITHM_DEFAULT

public static final java.lang.String ALGORITHM_DEFAULT
See Also:
Constant Field Values

ALGORITHM_PREFIXS

public static final java.lang.String[] ALGORITHM_PREFIXS

ALGORITHM_SHA

public static final java.lang.String ALGORITHM_SHA
See Also:
Constant Field Values
Method Detail

generate

public static java.lang.String generate(byte[] bytes)
Generate a digest (String) from the byte[].

Parameters:
bytes - byte array used to create the digest
Returns:
String the digest

generate

public static java.lang.String generate(java.lang.String str)
Generate a digest (String) from the String.

Parameters:
str - String used to create the digest
Returns:
String the digest

isHashed

public static boolean isHashed(java.lang.String str)
Parameters:
str - String value will be check to see if it is a hashed String
Returns:
boolean true if it is a hashed String

main

public static void main(java.lang.String[] args)
Parameters:
args - (not used)

validate

public static boolean validate(java.lang.String hashed,
                               byte[] bytes)
Parameters:
hashed - String containing a hash value
bytes - Byte array that will be used to compare with the hash value
Returns:
boolean true if they match

validate

public static boolean validate(java.lang.String hashed,
                               java.lang.String str)
Parameters:
hashed - String containing a hash value
str - String that will be used to compare with the hash value
Returns:
boolean true if they match


View/submit a bug or feature

For further API reference and developer documentation, see www.openptk.org. That documentation contains more detailed, developer-targeted descriptions, definitions of terms, workarounds, and working code examples.

Copyright (C) 2008-2012, Project OpenPTK. All Rights Reserved