From owner-svn-src-all@freebsd.org Fri Jun 19 06:23:55 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A483E340D55; Fri, 19 Jun 2020 06:23:55 +0000 (UTC) (envelope-from fernape@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49p7zv3sb2z4byL; Fri, 19 Jun 2020 06:23:55 +0000 (UTC) (envelope-from fernape@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7FE6A16A4A; Fri, 19 Jun 2020 06:23:55 +0000 (UTC) (envelope-from fernape@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 05J6NtmD013186; Fri, 19 Jun 2020 06:23:55 GMT (envelope-from fernape@FreeBSD.org) Received: (from fernape@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 05J6NtTD013185; Fri, 19 Jun 2020 06:23:55 GMT (envelope-from fernape@FreeBSD.org) Message-Id: <202006190623.05J6NtTD013185@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: fernape set sender to fernape@FreeBSD.org using -f From: =?UTF-8?Q?Fernando_Apestegu=c3=ada?= Date: Fri, 19 Jun 2020 06:23:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r362365 - head/sbin/md5 X-SVN-Group: head X-SVN-Commit-Author: fernape X-SVN-Commit-Paths: head/sbin/md5 X-SVN-Commit-Revision: 362365 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Jun 2020 06:23:55 -0000 Author: fernape (ports committer) Date: Fri Jun 19 06:23:55 2020 New Revision: 362365 URL: https://svnweb.freebsd.org/changeset/base/362365 Log: md5(1): Add EXAMPLES section Add EXAMLES covering -c, -s and -r Approved by: bcr@, 0mp@ Differential Revision: https://reviews.freebsd.org/D25278 Modified: head/sbin/md5/md5.1 Modified: head/sbin/md5/md5.1 ============================================================================== --- head/sbin/md5/md5.1 Fri Jun 19 05:54:15 2020 (r362364) +++ head/sbin/md5/md5.1 Fri Jun 19 06:23:55 2020 (r362365) @@ -1,5 +1,5 @@ .\" $FreeBSD$ -.Dd June 15, 2020 +.Dd June 19, 2020 .Dt MD5 1 .Os .Sh NAME @@ -95,6 +95,48 @@ utilities exit 0 on success, and 2 if at least one file does not have the same hash as the .Fl c option. +.Sh EXAMPLES +Calculate the MD5 checksum of the string +.Dq Hello . +.Bd -literal -offset indent +$ md5 -s Hello +MD5 ("Hello") = 8b1a9953c4611296a827abf8c47804d7 +.Ed +.Pp +Same as above, but note the absence of the newline character in the input +string: +.Bd -literal -offset indent +$ echo -n Hello | md5 +8b1a9953c4611296a827abf8c47804d7 +.Ed +.Pp +Calculate the checksum of multiple files reversing the output: +.Bd -literal -offset indent +$ md5 -r /boot/loader.conf /etc/rc.conf +ada5f60f23af88ff95b8091d6d67bef6 /boot/loader.conf +d80bf36c332dc0fdc479366ec3fa44cd /etc/rc.conf +.Ed +.Pp +Write the digest for +.Pa /boot/loader.conf +in a file named +.Pa digest . +Then calculate the checksum again and validate it against the checksum string +extracted from the +.Pa digest +file: +.Bd -literal -offset indent +$ md5 /boot/loader.conf > digest && md5 -c $(cut -f2 -d= digest) /boot/loader.conf +MD5 (/boot/loader.conf) = ada5f60f23af88ff95b8091d6d67bef6 +.Ed +.Pp +Same as above but comparing the digest against an invalid string +.Pq Dq randomstring , +which results in a failure. +.Bd -literal -offset indent +$ md5 -c randomstring /boot/loader.conf +MD5 (/boot/loader.conf) = ada5f60f23af88ff95b8091d6d67bef6 [ Failed ] +.Ed .Sh SEE ALSO .Xr cksum 1 , .Xr md5 3 ,