Different MD5 value when using 'digest' command


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Different MD5 value when using 'digest' command
# 1  
Old 12-02-2010
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:

Code:
echo hello|digest -a md5
b1946ac92492d2347c6235b4d2611184

Code:
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:

Code:
> 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
# 2  
Old 12-02-2010
There is a vast difference between 'hello' and 'echo hello'. Try this:

Code:
echo -n 'hello' | digest -a md5

The -n tells it not to put a newline on the end.
# 3  
Old 12-02-2010
thanks for the response.
Now i'm getting:
Code:
> 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 differentSmilie

Any ideas?

Regards,
Zaff
# 4  
Old 12-02-2010
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
This User Gave Thanks to Corona688 For This Post:
# 5  
Old 12-02-2010
Excellent! that's worked.

Thanks for your help and the quick response.Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to reverse the b64 format(encoded b64(b64(md5($pass)))) into md5 hash format?

I have about 1500 rows (encoded b64(b64(md5($pass))) algorythm) in a file. I would like reverse the b64 into md5 hash format. How could I do that from command line? So I need only the correct md5 hash formats. These row format: 4G5qc2WQzGES6QkWAUgl5w P9tKxonBOg3ymr8vOBLnDA... (1 Reply)
Discussion started by: freeroute
1 Replies

2. Red Hat

Digest::md5 needed for RHEL 6.4

Hey, I've got a package that requires 'Digest:md5' to be installed but I can't locate a source for it from Redhat. Poking around on the internet I found some stuff that seemed to be for RHEL 6.4 but when I had yum try a local install it gives me this error. Transaction Check Error: file... (3 Replies)
Discussion started by: DustinT
3 Replies

3. Shell Programming and Scripting

Using Wget with Digest Authentication

I’m trying to use wget 1.13.4 from a command line to access a web page using Digest Authentication on a Tomcat server, and I keep getting HTTP/1.1 401 Unauthorized response. Below is my code and the response. Any suggestions would be appreciated. wget --debug --server-response --user-agent=""... (5 Replies)
Discussion started by: mtarkowski
5 Replies

4. Solaris

md5 checksum what does it do

Hello good people, I came across md5 checksum. Can anyone please explain to me what it does and if possible an example of how to use it? Thank you very much (1 Reply)
Discussion started by: cjashu
1 Replies

5. Shell Programming and Scripting

Help with MD5 script

Hi, I tried to write script, which would be able to generate MD5 sums into txt file.. But It won't work.. (I've been trying to fix that over 4 hours, but nothing helps) Here it is #!/bin/bash FILE="nothing1" POST="nothing2" I=1 while do FILE=`ls -ltR | grep "^-" | tr -s "... (1 Reply)
Discussion started by: TheBarnacle
1 Replies

6. Shell Programming and Scripting

Create md5 sums and archive the resulting md5 files

Hello everyone, I am looking to basically creating md5sum files for all iso files in a directory and archive the resulting md5 files into a single archive in that very same directory. I worked out a clumsy solution such as: #find files for which md5sum are to be created and store the... (1 Reply)
Discussion started by: SurfTranquille
1 Replies

7. Linux

Need Help: MD5

I am trying to compare two identical files by using md5 command, but cant get the right command parameters Please help me with any examples. All I want is to know how to compare two identical files which are residing on two different machines in my local network, for example: Host_A -... (6 Replies)
Discussion started by: greenja
6 Replies

8. UNIX for Advanced & Expert Users

Running command "md5" on remote host not working.

My question is very strange. I can run ls command on remote host using ssh successfully. but when i try to run /sbin/md5 command on remote host. it doesnt run and get back to me on command prompt. md5 command is exist on remote host. This is what i tried which ran successfully. Query -... (1 Reply)
Discussion started by: ynilesh
1 Replies

9. UNIX for Advanced & Expert Users

Digest MD5

Dear Guys , Am sorry i ask alot , but i do not know that much about perl , cgi , MD5 ! now i installed MD5 and Digest MD5 to my solaries 7 sparc machine . when i execute the command : $perl Makefile.PL i get the follwoing error message ,, please tell me how to fix it , i need... (11 Replies)
Discussion started by: tamemi
11 Replies

10. Shell Programming and Scripting

Md5

Does anyone know a scipt that includes MD5. I need to run a script that includes MD5 encryption. Thanks (1 Reply)
Discussion started by: duncang3
1 Replies
Login or Register to Ask a Question