aboutsummaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorFernando ApesteguĂ­a <fernape@FreeBSD.org>2020-06-19 06:23:55 +0000
committerFernando ApesteguĂ­a <fernape@FreeBSD.org>2020-06-19 06:23:55 +0000
commit83d742d661c3d3581699b005bcb5085b02792cd2 (patch)
tree71eff6f7ee8badaaf3569995e3a8a2b5b8d651e4 /sbin
parentf03407403493fd8e4b3eb38220d5d6dea98d40c5 (diff)
downloadsrc-83d742d661c3d3581699b005bcb5085b02792cd2.tar.gz
src-83d742d661c3d3581699b005bcb5085b02792cd2.zip
md5(1): Add EXAMPLES section
Add EXAMLES covering -c, -s and -r Approved by: bcr@, 0mp@ Differential Revision: https://reviews.freebsd.org/D25278
Notes
Notes: svn path=/head/; revision=362365
Diffstat (limited to 'sbin')
-rw-r--r--sbin/md5/md5.144
1 files changed, 43 insertions, 1 deletions
diff --git a/sbin/md5/md5.1 b/sbin/md5/md5.1
index 1c5964297ffc..e6b29233c399 100644
--- a/sbin/md5/md5.1
+++ b/sbin/md5/md5.1
@@ -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 ,