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                           [EMAIL PROTECTED]

Reply via email to