using md5 initwith shell?


 
Thread Tools Search this Thread
Operating Systems Linux using md5 initwith shell?
# 1  
Old 04-07-2010
Network using md5 initwith shell?

Hi guys,
Hi have a little problem with md5 digest.I want to translate in bash language this function in python:

Code:
digest = int(md5(value).hexdigest(),16)

(it's an md5 update)

how i "translate" this function in bash or openssl utility in bash?
Thanks

Last edited by pludi; 04-07-2010 at 06:50 AM.. Reason: code tags, please...
# 2  
Old 04-07-2010
Roughly?
Code:
digest=$( echo "ibase=16; $( echo $value | md5sum | cut -f1 -d ' ' | tr '[a-z]' '[A-Z]' )" | bc )

# 3  
Old 04-09-2010
Thanks but not the same resultSmilie
For example
Code:
echo -n "0011223344556677889910111213141516171819"|md5sum| cut -f1 -d ' ' | tr '[a-z]' '[A-Z]' | bc
19498340999655919679390993985391

and the pyton gives:

Code:
digest = int(md5(0011223344556677889910111213141516171819).hexdigest(),16)
37615660562377680210092719805016069009

whats the matter??

Last edited by pludi; 04-09-2010 at 06:57 AM.. Reason: code tags, please...
# 4  
Old 04-09-2010
It's because you didn't specify the input base. Compare
Code:
$ echo -n "0011223344556677889910111213141516171819" | md5sum | cut -f1 -d ' ' | tr '[a-z]' '[A-Z]' | bc
19498340999655919679390993985391
$ ( echo "ibase=16"; echo -n "0011223344556677889910111213141516171819" | md5sum | cut -f1 -d ' ' | tr '[a-z]' '[A-Z]' ) | bc
37615660562377680210092719805016069009

From man bc (emphasis added)
Quote:
Input numbers may contain the characters 0-9 and A-F. (Note: They must be capitals. Lower case letters are variable names.) Single digit numbers always have the value of the digit regardless of the value of ibase. (i.e. A = 10.) For multi-digit numbers, bc changes all input digits greater or equal to ibase to the value of ibase-1. This makes the number FFF always be the largest 3 digit number of the input base.
That means that, with an ibase default of 10, A-F are changed to the number 9:
Code:
$ echo -n "0011223344556677889910111213141516171819" | md5sum | cut -f1 -d ' ' | tr '[a-z]' '[A-Z]'
1C4C8340AAE655C1F67F3F0CF3A85391
$ echo -n "0011223344556677889910111213141516171819" | md5sum | cut -f1 -d ' ' | tr '[a-z]' '[A-Z]'| bc
19498340999655919679390993985391

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. Solaris

MD5 checksum

Hi Guys, I have about MD5 checksum so many times but I can't figure out how to use it. Can someone please show me how to perform an MD5 checksum? Thanks a lot guys. (1 Reply)
Discussion started by: cjashu
1 Replies

3. 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

4. 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

5. 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

6. 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

7. UNIX for Dummies Questions & Answers

MD5 missmatch

I think it's a problem of gtar, but i'm note sure... I use gtar to create an archive from a directory then i use md5 to get an md5 string for the archive bzip2 to compress the archive and md5 again for the compressed archive. I send the file to my backup machine. When i download the... (1 Reply)
Discussion started by: noratx
1 Replies

8. UNIX for Dummies Questions & Answers

Hashing or MD5

Hi, how can one find that which encryption algorithm the system is using for keeping the user password in the /etc/passwd or /etc/shadow file. Is it 1: Hashing ( which considers only first 5 letters of password) 2: MD5 (Which allows arbitry length passwords) Thanks, ~amit (0 Replies)
Discussion started by: amit4g
0 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