|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.hsqldb.lib.MD5
Provides a static utility interface to an MD5 digest algorithm obtained through the java.security.MessageDigest spi.
Database end-users may wish to access the services of this class to provide, for instance, application user lookup tables with one-way password encryption. For example:
-- DDL CREATE TABLE USERS(UID INTEGER IDENTITY, UNAME VARCHAR, UPASS VARCHAR, UNIQUE(UNAME)) CREATE ALIAS MD5 FOR "org.hsqldb.lib.MD5.encodeString" -- DML & DQL INSERT INTO USERS(UNAME, UPASS) VALUES('joe', MD5('passwd')) UPDATE USERS SET UPASS = MD5('newpasswd') WHERE UNAME = 'joe' AND UPASS = MD5('oldpasswd') SELECT UID FROM USERS WHERE UNAME = 'joe' AND UPASS = MD5('logonpasswd')NOTE:
Although it is possible that a particular JVM / application installation may encounter NoSuchAlgorithmException when attempting to get a jce MD5 message digest generator, the likelyhood is very small for almost all JDK/JRE 1.1 and later JVM implementations, as the Sun java.security package has come, by default, with a jce MD5 message digest generator since JDK 1.1 was released. The HSLQLDB project could have provided an MD5 implementation to guarantee presence, but this class is much more lightweight and still allows clients to install / use custom implementations through the java.security.MessageDigest spi, for instance if there is no service provided by default under the target JVM of choice or if a client has developed / provides, say, a faster MD5 message digest implementation. In short, this class is a convenience that allows HSQLDB SQL Function and Stored Procedure style access to any underlying MD5 message digest algorithm obtained via the java.security.MessageDigest spi
Constructor Summary | |
MD5()
|
Method Summary | |
static byte[] |
digestBytes(byte[] data)
Retrieves a byte sequence representing the MD5 digest of the specified byte sequence. |
static byte[] |
digestString(String string,
String encoding)
Retrieves a byte sequence representing the MD5 digest of the specified character sequence, using the specified encoding to first convert the character sequence into a byte sequence. |
static String |
encodeString(String string,
String encoding)
Retrieves a hexidecimal character sequence representing the MD5 digest of the specified character sequence, using the specified encoding to first convert the character sequence into a byte sequence. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public MD5()
Method Detail |
public static final String encodeString(String string, String encoding) throws RuntimeException
string
- the string to encode.encoding
- the encoding used to convert the string into the
byte sequence to submit for MD5 digest
HsqlUnsupportedOperationException
- if an MD5 digest
algorithm is not available through the
java.security.MessageDigest spi or the requested
encoding is not available
RuntimeException
public static byte[] digestString(String string, String encoding) throws RuntimeException
string
- the string to digest.encoding
- the character encoding.
HsqlUnsupportedOperationException
- if an MD5 digest
algorithm is not available through the
java.security.MessageDigest spi or the requested
encoding is not available
RuntimeException
public static final byte[] digestBytes(byte[] data) throws RuntimeException
data
- the data to digest.
HsqlUnsupportedOperationException
- if an MD5 digest
algorithm is not available through the
java.security.MessageDigest spi
RuntimeException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |