[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openssl-users
Subject:    RE: Reading from standard input
From:       "Steven Reddie" <smr () essemer ! com ! au>
Date:       2005-08-30 4:12:40
Message-ID: 200508300412.j7U4CioE017595 () mail09 ! syd ! optusnet ! com ! au
[Download RAW message or body]

It's the same as your original problem: different end-of-line markers

Try this instead:
	echo -n "1122" | openssl dgst -md5

-----Original Message-----
From: owner-openssl-users@openssl.org
[mailto:owner-openssl-users@openssl.org] On Behalf Of Roberto Arias Alegria
Sent: Tuesday, 30 August 2005 2:01 PM
To: openssl-users@openssl.org
Subject: Re: Reading from standard input

Thanks people,

Yeah I think the end of line was the key. After reading your posts I
realised that I needed this:
echo "mytext" | openssl dgst -md5

Anyway, I don't know why I got different hashes:

Using openssl:
 echo "1122" | openssl dgst -md5
 01ebeaafc334e503f4acc94a18df9fa5

and using MySQL:
 SELECT md5("1122");
 3b712de48137572f3849aabd5666a4e3

//roberto8080


On 8/29/05, Victor Duchovni <Victor.Duchovni@morganstanley.com> wrote:
> On Mon, Aug 29, 2005 at 06:42:07PM -0500, Roberto Arias Alegria wrote:
> 
> > Hello new around here,
> >
> > I'm just new to OpenSSL and I'd like to calculate a MD5 digest, I 
> > used the command
> >
> > openssl dgst -md5 file.txt
> >
> > and I got a digest of the file, but I want a digest of what is
> > *inside* the file, a text string, not the file itself, it is 
> > possible to do this?
> >
> 
> The difference is the newline at the end of the string on each line of 
> the file. To checksum each line (using the shell and openssl rather 
> than the much easier Perl with Digest::MD5) but omit the terminating new
line:
> 
>     #! /bin/sh
>     SAVEIFS="$IFS"
>     IFS="
>     "
>     while read line
>     do
>         printf "%s" "$line" | openssl dgst -md5
>     done < inputfile
>     IFS="$SAVEIFS"
> 
> --
>         Viktor.
> ______________________________________________________________________
> OpenSSL Project                                 http://www.openssl.org
> User Support Mailing List                    openssl-users@openssl.org
> Automated List Manager                           majordomo@openssl.org
>
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majordomo@openssl.org

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majordomo@openssl.org
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic