Reading from standard input

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Reading from standard input

Roberto Arias Alegria
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?


//roberto8080
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [hidden email]
Automated List Manager                           [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Reading from standard input

Ignacio Butler
you can use the md5sum command...

$md5sum file.txt

On 8/29/05, Roberto Arias Alegria <[hidden email]> 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?
>
>
> //roberto8080
> ______________________________________________________________________
> OpenSSL Project                                 http://www.openssl.org
> User Support Mailing List                    [hidden email]
> Automated List Manager                           [hidden email]
>


--
 -o)
  / \\
_\_V
cuando no tenes paredes, no necesitas ventanas
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [hidden email]
Automated List Manager                           [hidden email]
Reply | Threaded
Open this post in threaded view
|

RE: Reading from standard input

Steven Reddie
In reply to this post by Roberto Arias Alegria
Your question doesn't make much sense.  A "digest of the file" is exactly
the same as "a digest of what is *inside* the file".  If you mean that you
want a digest of a particular portion of the contents of the file then
you'll need to extract that yourself.

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Roberto Arias Alegria
Sent: Tuesday, 30 August 2005 9:42 AM
To: [hidden email]
Subject: Reading from standard input

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?


//roberto8080
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [hidden email]
Automated List Manager                           [hidden email]

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [hidden email]
Automated List Manager                           [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Reading from standard input

Victor Duchovni
In reply to this post by Roberto Arias Alegria
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                    [hidden email]
Automated List Manager                           [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Reading from standard input

Roberto Arias Alegria
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 <[hidden email]> 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                    [hidden email]
> Automated List Manager                           [hidden email]
>
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [hidden email]
Automated List Manager                           [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Reading from standard input

Joshua Juran
On Aug 30, 2005, at 12:00 AM, Roberto Arias Alegria wrote:

> 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

Because echo is appending a linefeed to the string.

        $ echo -n "1122" | openssl dgst -md5
        3b712de48137572f3849aabd5666a4e3

Josh

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [hidden email]
Automated List Manager                           [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Reading from standard input

Victor Duchovni
In reply to this post by Roberto Arias Alegria
On Mon, Aug 29, 2005 at 11:00:33PM -0500, Roberto Arias Alegria wrote:

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

    $ echo '' | wc
    $ printf '' | wc

--
        Viktor.
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [hidden email]
Automated List Manager                           [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Reading from standard input

Rich Salz
In reply to this post by Roberto Arias Alegria
> Anyway, I don't know why I got different hashes

The newline that echo adds.  Try
        echo -n 1122 | openssl dgst -md5

--
Rich Salz                  Chief Security Architect
DataPower Technology       http://www.datapower.com
XS40 XML Security Gateway  http://www.datapower.com/products/xs40.html

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [hidden email]
Automated List Manager                           [hidden email]
Reply | Threaded
Open this post in threaded view
|

RE: Reading from standard input

Steven Reddie
In reply to this post by Roberto Arias Alegria
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: [hidden email]
[mailto:[hidden email]] On Behalf Of Roberto Arias Alegria
Sent: Tuesday, 30 August 2005 2:01 PM
To: [hidden email]
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 <[hidden email]> 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                    [hidden email]
> Automated List Manager                           [hidden email]
>
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [hidden email]
Automated List Manager                           [hidden email]

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [hidden email]
Automated List Manager                           [hidden email]