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 FUNCTION MD5(VARCHAR(100)) RETURNS VARCHAR(16) LANGUAGE JAVA EXTERNAL NAME "org.hsqldb.lib.MD5.encode" -- 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 @author boucherb@users.sourceforge.net @version 1.9.0 @since 1.9.0
|
|