Sponsored Content
Full Discussion: Script to compare md5
Special Forums UNIX Desktop Questions & Answers Script to compare md5 Post 302508308 by giova on Sunday 27th of March 2011 07:20:32 PM
Old 03-27-2011
Script to compare md5

From couple of hours i try to do a script to compare file MD5.
Help would be very appreciated Smilie

First i read the md5 stored into a text file (no problem):
Code:
 md5=`grep -P "^[a-fA-F0-9]{32}" $file`

then i want to calculate the checksum and store it :
Code:
cmd5=`md5sum licence.gvcl`

then problems arrives, i want to compare both:
Code:
 if [[ $md5 == $cmd5 ]]
           then
               echo cool md5 is ok
           else
              echo FAIL MD5
              echo $md5
              echo $rmd5
 
           fi

I'm lost because on screen i see this:
Quote:
FAIL MD5
ab4f63f9ac65152575886860dde480a1 myfile.txt
ab4f63f9ac65152575886860dde480a1 myfile.txt
looks like md5 or cmd5 is not a string?
how to fix it please?
 

10 More Discussions You Might Find Interesting

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

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

3. Shell Programming and Scripting

Help with md5 in PERL

I am a newbie in programming in Perl. My problem is that this unix command is embedded in Perl but it gives an empty output. Here's the code: $temp = `md5 "../Directory String/..." | awk {'print $NF'} > "../Directory/file.txt"`; The output file should contain the md5 hash value of the... (2 Replies)
Discussion started by: ianebaj
2 Replies

4. Shell Programming and Scripting

[Bash] MD5 Checks with Script.

Hi. I'm triyng to make a Bash Script that checks (recursively) the MD5 from all the files in a certain directory and compare them against some other check that should be already done and saved in a file. I've reached to the point where i have the MD5 from the file and the MD5 that the script... (1 Reply)
Discussion started by: BiFo
1 Replies

5. Shell Programming and Scripting

Need to create a simple script using MD5, SSH...

Hi all, I am brand new to these forums and I am a brand new UNIX Administartor. Don't know any scripting yet :wall:, and would like to learn as my boss is slowly letting me understand everything about being a Sys/*Nix Admin. He created this script which I am trying to replicate because I lost it... (54 Replies)
Discussion started by: zixzix01
54 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. 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

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

9. Shell Programming and Scripting

scp script with MD5

I have more than one file in my directory & I want to SCP them all with MD5 verification of local & remote file, Problem is that the script gets stop after scp one file. Below is the code. #!/usr/bin/bash cd /application/datafolder/my/ ls > my_file_list.txt while read fname do ... (7 Replies)
Discussion started by: m_raheelahmed
7 Replies

10. 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
md5(n)							   MD5 Message-Digest Algorithm 						    md5(n)

__________________________________________________________________________________________________________________________________________________

NAME
md5 - MD5 Message-Digest Algorithm SYNOPSIS
package require Tcl 8.2 package require md5 ?2.0.7? ::md5::md5 ?-hex? [ -channel channel | -file filename | string ] ::md5::hmac ?-hex? -key key [ -channel channel | -file filename | string ] ::md5::MD5Init ::md5::MD5Update token data ::md5::MD5Final token ::md5::HMACInit key ::md5::HMACUpdate token data ::md5::HMACFinal token _________________________________________________________________ DESCRIPTION
This package is an implementation in Tcl of the MD5 message-digest algorithm as described in RFC 1321 (1). This algorithm takes an arbi- trary quantity of data and generates a 128-bit message digest from the input. The MD5 algorithm is related to the MD4 algorithm (2) but has been strengthened against certain types of potential attack. MD5 should be used in preference to MD4 for new applications. If you have critcl and have built the tcllibc package then the implementation of the hashing function will be performed by compiled code. Alternatively if you have either cryptkit or Trf then either of these can be used to accelerate the digest computation. If no suitable com- piled package is available then the pure-Tcl implementation wil be used. The programming interface remains the same in all cases. Note the previous version of this package always returned a hex encoded string. This has been changed to simplify the programming interface and to make this version more compatible with other implementations. To obtain the previous usage, either explicitly specify package ver- sion 1 or use the -hex option to the md5 command. COMMANDS
::md5::md5 ?-hex? [ -channel channel | -file filename | string ] Calculate the MD5 digest of the data given in string. This is returned as a binary string by default. Giving the -hex option will return a hexadecimal encoded version of the digest. The data to be hashed can be specified either as a string argument to the md5 command, or as a filename or a pre-opened channel. If the -filename argument is given then the file is opened, the data read and hashed and the file is closed. If the -channel argument is given then data is read from the channel until the end of file. The channel is not closed. Only one of -file, -channel or string should be given. ::md5::hmac ?-hex? -key key [ -channel channel | -file filename | string ] Calculate an Hashed Message Authentication digest (HMAC) using the MD5 digest algorithm. HMACs are described in RFC 2104 (3) and provide an MD5 digest that includes a key. All options other than -key are as for the ::md5::md5 command. PROGRAMMING INTERFACE
For the programmer, the MD5 hash can be viewed as a bucket into which one pours data. When you have finished, you extract a value that is derived from the data that was poured into the bucket. The programming interface to the MD5 hash operates on a token (equivalent to the bucket). You call MD5Init to obtain a token and then call MD5Update as many times as required to add data to the hash. To release any resources and obtain the hash value, you then call MD5Final. An equivalent set of functions gives you a keyed digest (HMAC). ::md5::MD5Init Begins a new MD5 hash. Returns a token ID that must be used for the remaining functions. ::md5::MD5Update token data Add data to the hash identified by token. Calling MD5Update $token "abcd" is equivalent to calling MD5Update $token "ab" followed by MD5Update $token "cb". See EXAMPLES. ::md5::MD5Final token Returns the hash value and releases any resources held by this token. Once this command completes the token will be invalid. The result is a binary string of 16 bytes representing the 128 bit MD5 digest value. ::md5::HMACInit key This is equivalent to the ::md5::MD5Init command except that it requires the key that will be included in the HMAC. ::md5::HMACUpdate token data ::md5::HMACFinal token These commands are identical to the MD5 equivalent commands. EXAMPLES
% md5::md5 -hex "Tcl does MD5" 8AAC1EE01E20BB347104FABB90310433 % md5::hmac -hex -key Sekret "Tcl does MD5" 35BBA244FD56D3EDF5F3C47474DACB5D % set tok [md5::MD5Init] ::md5::1 % md5::MD5Update $tok "Tcl " % md5::MD5Update $tok "does " % md5::MD5Update $tok "MD5" % md5::Hex [md5::MD5Final $tok] 8AAC1EE01E20BB347104FABB90310433 REFERENCES
[1] Rivest, R., "The MD5 Message-Digest Algorithm", RFC 1321, MIT and RSA Data Security, Inc, April 1992. (http://www.rfc-edi- tor.org/rfc/rfc1321.txt) [2] Rivest, R., "The MD4 Message Digest Algorithm", RFC 1320, MIT, April 1992. (http://www.rfc-editor.org/rfc/rfc1320.txt) [3] Krawczyk, H., Bellare, M. and Canetti, R. "HMAC: Keyed-Hashing for Message Authentication", RFC 2104, February 1997. (http://www.rfc-editor.org/rfc/rfc2104.txt) BUGS, IDEAS, FEEDBACK This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category md5 of the Tcllib SF Trackers [http://sourceforge.net/tracker/?group_id=12883]. Please also report any ideas for enhancements you may have for either package and/or documentation. SEE ALSO
md4, sha1 KEYWORDS
hashing, md5, message-digest, rfc 1320, rfc 1321, rfc 2104, security COPYRIGHT
Copyright (c) 2003, Pat Thoyts <patthoyts@users.sourceforge.net> md5 2.0.7 md5(n)
All times are GMT -4. The time now is 05:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy