Skip to content

akuroda/teradata-udf-sha2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SHA-2 UDF package for Teradata  Version 1.0 (2013-12-28)

Copyright (c) 2013 Akira Kuroda <akuroda@gmail.com>
See the LICENSE file for license rights and limitations (MIT)

1. Summary

This package includes UDFs which generates SHA-2 message digest.
For SHA-2 itself, refer FIPS PUB 180-4[1].


2. Syntax

 hash_sha256(varchar)
 hash_sha512(varchar)

These functions take one char/varchar argument of any length and
returns 256/512-bit hash value as hexadecimal format.
It does not accept NULL value.


3. Installation

1 unpack the archive and go to src directory
2 start bteq and login to teradata
3 register UDFs by runnning scripts in the src diretcory:
 .run file = hash_sha256.sql
 .run file = hash_sha512.sql
4 if you would like to validate hash value generated by the UDF, run
  test scripts in the test directory:
 for hash_256: sha256test_cre.sql, sha256test_ins.sql and sha256test_chk.sql
 for hash_512: sha512test_cre.sql, sha512test_ins.sql and sha512test_chk.sql


A. Rererences

[1] FIPS PUB 180-4
http://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf


B. Example

hash_sha256('abc')
 -> ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad
hash_sha512('abc')
 -> ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f