MD5 Message Digest UDF
About this download

This UDF implements the MD5 message-digest algorithm. The algorithm takes as input a message of arbitrary length and produces as output a 128-bit "fingerprint" or "message digest" of the input (RFC1321). This distribution contains full source code, a test suite, scripts, and documentation.


MD5 UDF package for Teradata  Version 2.0 (2008-05-08)

1. Summary

This package includes a UDF that generates MD5 message digest.
For MD5 itself, refer RFC1321[1].

2. Syntax


This function takes one char/varchar argument of arbitary length
and always returns 128-bit hash value as hexadecimal char(32) format.
It does not accept NULL value.

The name of the UDF is changed from there is an incompatibility
against previous release.
(see 4. History)

3. Installation

1 unpack the archive and go to src directory
2 start bteq and login to teradata
3 .run file = hash_md5.btq
4 if you would like to validate hash value generated by the UDF,
 run md5test_cre.sql, md5test_ins.sql and md5test_chck.sql in the test

You can edit md5.h to customize hash generation.
UDF_MD5_UPPERCASE: if set to 1 (default), generate MD5 result in upper case
UDF_MD5_COMPAT: if set to 1 (not default), generate same result as previous
 release (see 4. History)

4. History
Fixed MD5 algorithm that generates wrong result when the input length is
54 + 64*N bytes (N>= 0).

Removed malloc() function which may cause memory problem in UDF.

Fixed compilation issues on Windows platform.

5. Caveat
You should not use these function to encrypt password without 'salt'.

6. Author
KURODA Akira <>
Teradata Japan

A. Rererences
[1] Rivest, R., "The MD5 Message-Digest Algorithm", RFC 1321, April 1992.

B. Example

 -> d41d8cd98f00b204e9800998ecf8427e
 -> 0cc175b9c0f1b6a831c399e269772661
 -> 900150983cd24fb0d6963f7d28e17f72
hash_md5('message digest')
 -> f96b697d7cb7938d525a2f31aaf161d0
hash_md5('message digest')
 -> f96b697d7cb7938d525a2f31aaf161d0
 -> c3fcd3d76192e4007dfb496cca67e13b
 -> d174ab98d277d9f5a5611c2c9f419d9f
 -> 57edf4a22be3c955ac49da2e2107b67a