André Rothe · Jun 22, 2017

Hash values of columns

I try to find a function, which generates hash values of columns. In MS SQL Server I can use

select hashbytes('sha2_256', my_column) ...

to create hash values of my_column. Is it possible to use such things in Caché?

Thank you

0 948
Discussion (1)1
Log in or sign up to continue

I can't think of a built-in stored procedure for this, but it would be relatively simple to create one to wrap $System.Encryption.SHAHash(bitlength, text).

For example, approximating HASHBYTES with the features built in to $System.Encryption:

Class DC.Demo.SQL

ClassMethod HashBytes(pAlgorithm As %String, pText As %String) As %Binary [ SqlProc ]
    // Note: will result in <ILLEGAL VALUE> if pAlgorithm is not supported
    Quit $Case($ZConvert(pAlgorithm,"L"),


Use (in SAMPLES):

select top 5 Name,DC_Demo.SQL_HashBytes('sha2_512',DOB) from Sample.Person