Different MD5 value when using 'digest' command

Hi guys,
I need to anonymise some data; Some of it in an Oracle database and some in text files. I'm using the 'digest' command on Solaris 10 OS and an Oracle function to encode the data in the database. However, as a test, when i try to encode the same string in the dataabse ans OS, I get different values:

echo hello|digest -a md5
b1946ac92492d2347c6235b4d2611184
select SYS.DBMS_CRYPTO.HASH(UTL_I18N.STRING_TO_RAW(LOWER('hello'),'AL32UTF8'),2) from dual;
5D41402ABC4B2A76B9719D911017C592

After checking some online MD5 generators, all the online encoder produce
"5D41402ABC4B2A76B9719D911017C592" as the value.

I would like to know, why there's a difference in values?
I'm guessing it may have something to do with the characterset:

> locale
LANG=
LC_CTYPE=en_GB.ISO8859-1
LC_NUMERIC=en_GB.ISO8859-15
LC_TIME="C"
LC_COLLATE=en_GB.ISO8859-15
LC_MONETARY=en_GB.ISO8859-15
LC_MESSAGES=C
LC_ALL=

What would i need to change at the OS level so that both DB and OS produce same MD5 values?

Thanks in advance,
Zaff

There is a vast difference between 'hello' and 'echo hello'. Try this:

echo -n 'hello' | digest -a md5

The -n tells it not to put a newline on the end.

thanks for the response.
Now i'm getting:

> echo -n 'hello' | digest -a md5
348bda8e6bc630f8c6ea046c99489b92

...which is still wrong/different to the database generated value and values generated by online md5 encoderd.

I even tried placing 'hello' in the text file, still different:(

Any ideas?

Regards,
Zaff

Placing 'hello' in a text file would almost certainly add a newline.

Maybe your echo doesn't support -n and is printing "-n hello". Solaris shell utilities are frequently dumb like that. Try printf hello | digest -a md5

Excellent! that's worked.

Thanks for your help and the quick response.:b: