The MD4, MD5 using PLSQL hashing algorithms
Long back, around 2001, I download the script from http://www.gt.ed.net/keith/plsql/. This link is dead as of date. They are working plsql scripts that I have tested long back.
Introduction
MD4 and MD5 are one-way hashing algorithms designed to create compact, fixed-length (256 bit) digital signatures (checksums/fingerprints) by generating hashes that are unique and not reversible. They are also useful to provide secure hashing of passwords, especially when robust password validation is used or when a salt with a large key space is used to complicate the use of password dictionaries. MD4 is faster while MD5 is more secure.
The performance of the algorithms are quite slow in PL/SQL. You may try optimizing the algorithms’ implementation by compiling your PL/SQL code under Oracle9. Representing the character strings as an array of PLS_INTEGER ASCII codes would improve performance by eliminating the need for string manipulation operations. I will welcome, credit, and distribute these or other optimization fixes.
Oracle8 or greater does give you the ability to use procedures written in native languages that have binary operations for greater performance (I wrote this before Oracle8 existed). See www.fourmilab.ch/md5 for a good command-line version of MD5 for Unix and Windows platforms. Oracle8 also provides a standard obfuscation package for weak two-way encryption needs, which may be used to encrypt passwords with greater performance. Also, Oracle now has a security toolkit for more extensive cryptography needs.
LIMITATIONS AND NOTES
The algorithm may generate different signatures of the same message for different character sets. A fix for UTF/multi-byte character sets (standard character set used by Oracle8 or greater) has been submitted by Fred Brown and are available below as submitted.
Generic Bitwise Operations and MD4 Algorithm
The source is provided below for the generic bitwise operations package (bw) and the source of MD4 that uses this generic bitwise operations package. You must download and start bw.txt to use md4.txt.
Download bw.txt
Download md4.txt
Fast Unsigned 32-Bit Bitwise Operations and MD4/5 Algorithms FOR US7ASCII/SINGLE-BYTE CHARACTER SETS
The source is provided below for the unsigned 32-bit bitwise operations package (fbw) and the source of MD4/5 that uses this optimized bitwise operations package. You must download and start fast_bw.txt to use fast_md4.txt or fast_md5.txt.
Download fast_bw.txt
Download fast_md4.txt
Download fast_md5.txt
Fast Unsigned 32-Bit Bitwise Operations and MD5 Algorithms FOR UTF/MULTI-BYTE CHARACTER SETS
The source is provided below for the fast unsigned 32-bit bitwise operations and MD5 algorithm with UTF/multi-byte character sets (standard character set of Oracle8 or greater) fix as submitted by Fred Brown. You must download and start md5_main.txt to use md5_fast.txt.
Download md5_main.txt
Downloadmd5_fast.txt
Here is the original work and credit for the author.
/**************************************************************************
**
** Fast 32-bit Unsigned Binary Operations Library
**
** Version 1.0, 6/11/98
** Licensing updated 4/29/02
**
** Based on Kevin Taufner’s version 1.0, 7/20/97, Util package.
**
** Written by Keith Gardner
** Email: keith.gardner@earthlink.net
**
** Please send comments, corrections, and improvements.
**
**————————————————————————-
**
** Copyright (C) 1998, 2002 Wallace Keith Gardner.
** All rights reserved.
**
** This file is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** You must download, read, agree, and retain a copy of the GNU Lesser
** General Public License with this software. It can be found at:
**
** http://cellar.sourceforge.net/lesser.txt
**
** You must download, read, agree, and retain a copy of the Terms
** of Use and Disclaimer with this software. It can be found at:
**
** http://cellar.sourceforge.net/terms.txt
**
***************************************************************************/