Sponsored Content
Top Forums Shell Programming and Scripting Md5sum is running very slowly Post 302886121 by Corona688 on Wednesday 29th of January 2014 06:01:22 PM
Old 01-29-2014
Code:
$ cat md5line.c

#include <openssl/md5.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>

int main()
{
        int n;
        MD5_CTX c;
        unsigned char buf[1024], out[MD5_DIGEST_LENGTH];

        while(fgets(buf, 1024, stdin))
        {
                MD5_Init(&c);
                MD5_Update(&c, buf, strlen(buf)-1);
                MD5_Final(out, &c);

                for(n=0; n<MD5_DIGEST_LENGTH; n++)
                        printf("%02x", out[n]);
                fputs("\n",stdout);
        }

        return(0);
}

$ gcc md5line.c -o md5line -lssl # May need "openssl-dev" or something like that

$ printf "%s\n" a b c d e

a
b
c
d
e

$ echo "a" | md5sum # This includes the \n!
60b725f10c9c85c70d97880dfe8191b3  -

$ printf "a" | md5sum # Does not add \n
0cc175b9c0f1b6a831c399e269772661  -

$ printf "%s\n" a b c d e | ./md5line # My code also ignores \n
0cc175b9c0f1b6a831c399e269772661
92eb5ffee6ae2fec3ad71c777531578f
4a8a08f09d37b73795649038408b5f33
8277e0910d750195b448797616e091ad
e1671797c52e15f763380b45e841ec32

$

 

6 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

What is md5sum???

Hi all, I am kinda puzzled. When and Why do we use md5sum? I've read man pages for mp5sum, but didn't get anything out of it. Please, can someone explain this to me in couple of words. Thank you all. (1 Reply)
Discussion started by: solvman
1 Replies

2. Solaris

Delete and copy file(s) slowly(!?)

Hi all! I have to monitor space in V890 machine, Solaris 10 weekly, because there is Oracle DB on it with many datafiles which have been taken offline to make enough size. Sometime, one or more datafiles are big, they are 20GB, 40GB etc.. The problem I have encountered is the processing of... (5 Replies)
Discussion started by: trantuananh24hg
5 Replies

3. Shell Programming and Scripting

Running md5sum on a list of files

Hello, I would like to run md5sum on a list of files saved in a text file, and save the result in another file. (ie. md5sum `cat list.txt` > md5list.txt) I have tried several things, but I am always confronted to the same problem: some of the filenames have spaces. I have run sed on the... (5 Replies)
Discussion started by: SDelroen
5 Replies

4. Solaris

Sun StorageTek Common Array Manager 6.0 works very slowly

Hi! I have Sun StorageTek 2540 FC array and CAM works very slowly - I can wait for software response even more than 2 minutes... I run this software on Windows machine with Firefox Web Browser but speed is terrible... How can I make it works at least a little bit faster?.. (2 Replies)
Discussion started by: Sapfeer
2 Replies

5. SuSE

SLES 10 SP2 possible kernel problem, / slowly filling up

Hello Guys I first though about posting this to emergency but cause I fixed my issue with an reboot its not as important, more is important to me what caused this situation Some facts: OS: SLES 10 x64 SP2 (Virtualized Vmware ESX 3.5) / vmware tools status OK Soft: Oracle10g LVM... (1 Reply)
Discussion started by: kl1ngac1k
1 Replies

6. UNIX for Dummies Questions & Answers

Checking Unix Performance - Why is a process running slowly?

Hi Please can someone explain to me how they would go about monitoring the performance of a process in Unix. Lets say that a user is running a process in Unix but it seems to be taking a long time, whereas it completed a lot quicker yesterday. How would you go about investigating what is causing... (1 Reply)
Discussion started by: Sunny Sid
1 Replies
md5(3)								      OpenSSL								    md5(3)

NAME
MD2, MD4, MD5, MD2_Init, MD2_Update, MD2_Final, MD4_Init, MD4_Update, MD4_Final, MD5_Init, MD5_Update, MD5_Final - MD2, MD4, and MD5 hash functions SYNOPSIS
#include <openssl/md2.h> unsigned char *MD2(const unsigned char *d, unsigned long n, unsigned char *md); int MD2_Init(MD2_CTX *c); int MD2_Update(MD2_CTX *c, const unsigned char *data, unsigned long len); int MD2_Final(unsigned char *md, MD2_CTX *c); #include <openssl/md4.h> unsigned char *MD4(const unsigned char *d, unsigned long n, unsigned char *md); int MD4_Init(MD4_CTX *c); int MD4_Update(MD4_CTX *c, const void *data, unsigned long len); int MD4_Final(unsigned char *md, MD4_CTX *c); #include <openssl/md5.h> unsigned char *MD5(const unsigned char *d, unsigned long n, unsigned char *md); int MD5_Init(MD5_CTX *c); int MD5_Update(MD5_CTX *c, const void *data, unsigned long len); int MD5_Final(unsigned char *md, MD5_CTX *c); DESCRIPTION
MD2, MD4, and MD5 are cryptographic hash functions with a 128 bit output. MD2(), MD4(), and MD5() compute the MD2, MD4, and MD5 message digest of the n bytes at d and place it in md (which must have space for MD2_DIGEST_LENGTH == MD4_DIGEST_LENGTH == MD5_DIGEST_LENGTH == 16 bytes of output). If md is NULL, the digest is placed in a static array. The following functions may be used if the message is not completely stored in memory: MD2_Init() initializes a MD2_CTX structure. MD2_Update() can be called repeatedly with chunks of the message to be hashed (len bytes at data). MD2_Final() places the message digest in md, which must have space for MD2_DIGEST_LENGTH == 16 bytes of output, and erases the MD2_CTX. MD4_Init(), MD4_Update(), MD4_Final(), MD5_Init(), MD5_Update(), and MD5_Final() are analogous using an MD4_CTX and MD5_CTX structure. Applications should use the higher level functions EVP_DigestInit(3) etc. instead of calling the hash functions directly. NOTE
MD2, MD4, and MD5 are recommended only for compatibility with existing applications. In new applications, SHA-1 or RIPEMD-160 should be preferred. RETURN VALUES
MD2(), MD4(), and MD5() return pointers to the hash value. MD2_Init(), MD2_Update(), MD2_Final(), MD4_Init(), MD4_Update(), MD4_Final(), MD5_Init(), MD5_Update(), and MD5_Final() return 1 for success, 0 otherwise. CONFORMING TO
RFC 1319, RFC 1320, RFC 1321 SEE ALSO
sha(3), ripemd(3), EVP_DigestInit(3) HISTORY
MD2(), MD2_Init(), MD2_Update() MD2_Final(), MD5(), MD5_Init(), MD5_Update() and MD5_Final() are available in all versions of SSLeay and OpenSSL. MD4(), MD4_Init(), and MD4_Update() are available in OpenSSL 0.9.6 and above. 1.0.1e 2013-02-11 md5(3)
All times are GMT -4. The time now is 07:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy