|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.n52.security.common.crypto.DigestUtil
public final class DigestUtil
Contains some convenient utility methods related to MessageDigest
tasks.
Method Summary | |
---|---|
static boolean |
areEqualDigests(char[] a,
char[] b)
Method tests the both char[] on equality, ignoring the case. |
static boolean |
calculateAndTestForEquality(char[] expected,
char[] inputToCalculate,
String algorithm)
This is the prevered method to simple calculate a digest e.g. |
static boolean |
calculateAndTestForEquality(String expected,
String inputToCalculate,
String algorithm)
This is the prevered method to simple calculate a digest e.g. |
static byte[] |
calculateDigestOf(byte[] value,
String algorithm)
calcualates a digest for the given value with the given algorithm. |
static byte[] |
calculateDigestOf(char[] value,
String algorithm)
calcualates a digest for the given value with the given algorithm. |
static byte[] |
calculateDigestOf(CharBuffer value,
String algorithm)
calcualates a digest for the given value with the given algorithm. |
static byte[] |
calculateDigestOf(String value,
String algorithm)
calcualates a digest for the given value with the given algorithm. |
static char[] |
digestToCharArray(byte[] digest)
Method digestToCharArray converts a byte[] message digest to its two digit hexdecimal representation as chars. |
static String |
digestToString(byte[] digest)
Method digestToString converts a byte[] message digest to its two digit hexdecimal representation as string. |
static MessageDigest |
getMessageDigest(String algorithm)
convinient mehtod, wrapping the NoSuchAlgorithmException in an IllegalArgumentException if
algorithm not exists. |
static boolean |
isDigestAlgorithm(String algorithm)
Responsible for . |
static boolean |
isDigestOf(byte[] digest,
int expectedSize)
Method isDigestOf test if the given byte[] array is a digest. |
static boolean |
isDigestOf(byte[] digest,
MessageDigest algorithm)
Method isDigestOf test if the given byte[] array is a digest. |
static boolean |
isDigestOf(byte[] digest,
String algorithm)
Method isDigestOf test if the given byte[] array is a digest. |
static boolean |
isDigestOf(char[] digest,
int expectedSize)
Method isDigestOf test if the given char[] array is a digest. |
static boolean |
isDigestOf(char[] digest,
MessageDigest algorithm)
Method isDigestOf test if the given char[] array is a digest. |
static boolean |
isDigestOf(char[] digest,
String algorithm)
Method isDigestOf test if the given char[] array is a digest. |
static boolean |
isDigestOf(String digest,
int expectedSize)
Method isDigestOf test if the given String is a digest. |
static boolean |
isDigestOf(String digest,
MessageDigest algorithm)
Method isDigestOf test if the given char[] array is a digest. |
static boolean |
isDigestOf(String digest,
String algorithm)
Method isDigestOf test if the given char[] array is a digest. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static MessageDigest getMessageDigest(String algorithm)
NoSuchAlgorithmException
in an IllegalArgumentException
if
algorithm not exists.
public static boolean areEqualDigests(char[] a, char[] b)
a
- the first to check.b
- the second to check.
public static String digestToString(byte[] digest)
digest
- the digest !=null.
public static char[] digestToCharArray(byte[] digest)
digest
- the digest !=null.
public static boolean isDigestOf(byte[] digest, int expectedSize)
digest
- the digest !=nullexpectedSize
- the expectedSize.
public static boolean isDigestOf(char[] digest, int expectedSize)
digest
- the digest !=null.expectedSize
- the expectedSize of the digest in bytes as given by the algoritm
MessageDigest.getDigestLength()
Therewith this is the size in bytes, not the
size of the char array, e.g. MD5 has a size of 16, and the char[] is tested for a length of 32.
public static boolean isDigestOf(String digest, int expectedSize)
digest
- the digest !=null.expectedSize
- the expectedSize of the digest in bytes as given by the algoritm
MessageDigest.getDigestLength()
Therewith this is the size in bytes, not the
size of the String, e.g. MD5 has a size of 16, and the String is tested for a length of 32.
public static boolean isDigestOf(byte[] digest, MessageDigest algorithm)
digest
- the digest !=null.algorithm
- the algorithm !=null.
public static boolean isDigestOf(char[] digest, MessageDigest algorithm)
digest
- the digest !=null.algorithm
- the algorithm !=null.
public static boolean isDigestOf(String digest, MessageDigest algorithm)
digest
- the digest !=null.algorithm
- the algorithm !=null.
public static boolean isDigestOf(byte[] digest, String algorithm)
digest
- the digest !=null.algorithm
- the algorithm !=null.
IllegalArgumentException
- if algorithm not supported.public static boolean isDigestOf(char[] digest, String algorithm)
digest
- the digest !=null.algorithm
- the method !=null.
java.security.IllegalArgumentException
- if algorithm not supported.public static boolean isDigestOf(String digest, String algorithm)
digest
- the digest !=null.algorithm
- the method !=null.
IllegalArgumentException
- if algorithm not supported.public static final byte[] calculateDigestOf(byte[] value, String algorithm)
public static final byte[] calculateDigestOf(char[] value, String algorithm)
public static final byte[] calculateDigestOf(String value, String algorithm)
public static final byte[] calculateDigestOf(CharBuffer value, String algorithm)
public static boolean isDigestAlgorithm(String algorithm)
passwordEncryptionAlg
-
public static boolean calculateAndTestForEquality(char[] expected, char[] inputToCalculate, String algorithm)
expected
- the expected digest as char array.inputToCalculate
- the orginal password chars, from with first the digest is calculated.algorithm
- the algorithm used to calculate the digest from the input.
public static boolean calculateAndTestForEquality(String expected, String inputToCalculate, String algorithm)
expected
- the expected digest as char array.inputToCalculate
- the orginal password chars, from with first the digest is calculated.algorithm
- the algorithm used to calculate the digest from the input.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |