summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
Diffstat (limited to 'sbin')
-rw-r--r--sbin/md5/md5.15
-rw-r--r--sbin/md5/md5.c17
2 files changed, 15 insertions, 7 deletions
diff --git a/sbin/md5/md5.1 b/sbin/md5/md5.1
index 2eb9280..153054a 100644
--- a/sbin/md5/md5.1
+++ b/sbin/md5/md5.1
@@ -3,7 +3,7 @@
md5 \- calculate a message-digest fingerprint (checksum) for a file
.SH SYNOPSIS
.B md5
-[ -t | -x | -sstring | filename(s) ]
+[ -p | -t | -x | -sstring | filename(s) ]
.SH DESCRIPTION
.B md5
takes as input a message of arbitrary length and produces
@@ -26,6 +26,9 @@ must be the last objects on the command line.
.B -sstring
prints a checksum of the given "string".
.PP
+.B -p
+echos stdin to stdout and appends the MD5 sum to stdout.
+.PP
.B -t
runs a built-in time trial.
.PP
diff --git a/sbin/md5/md5.c b/sbin/md5/md5.c
index afa8ef8..72af3eb 100644
--- a/sbin/md5/md5.c
+++ b/sbin/md5/md5.c
@@ -1,5 +1,5 @@
/*
- * $Id$
+ * $Id: md5.c,v 1.2 1995/02/20 00:48:50 phk Exp $
*
* Derived from:
*/
@@ -36,7 +36,7 @@
static void MDString PROTO_LIST((char *));
static void MDTimeTrial PROTO_LIST((void));
static void MDTestSuite PROTO_LIST((void));
-static void MDFilter PROTO_LIST((void));
+static void MDFilter PROTO_LIST((int));
/* Main driver.
@@ -61,6 +61,8 @@ main(argc, argv)
MDString(argv[i] + 2);
else if (strcmp(argv[i], "-t") == 0)
MDTimeTrial();
+ else if (strcmp(argv[i], "-p") == 0)
+ MDFilter(1);
else if (strcmp(argv[i], "-x") == 0)
MDTestSuite();
else {
@@ -71,7 +73,7 @@ main(argc, argv)
printf("MD5 (%s) = %s\n", argv[i], p);
}
else
- MDFilter();
+ MDFilter(0);
return (0);
}
@@ -94,7 +96,7 @@ MDTimeTrial()
{
MD5_CTX context;
time_t endTime, startTime;
- unsigned char block[TEST_BLOCK_LEN], digest[16];
+ unsigned char block[TEST_BLOCK_LEN];
unsigned int i;
char *p;
@@ -151,14 +153,17 @@ MDTestSuite()
* Digests the standard input and prints the result.
*/
static void
-MDFilter()
+MDFilter(int pipe)
{
MD5_CTX context;
int len;
unsigned char buffer[BUFSIZ], digest[16];
MD5Init(&context);
- while (len = fread(buffer, 1, BUFSIZ, stdin))
+ while (len = fread(buffer, 1, BUFSIZ, stdin)) {
+ if(pipe && (len != fwrite(buffer, 1, len, stdout)))
+ perror(stdout);
MD5Update(&context, buffer, len);
+ }
printf("%s\n", MD5End(&context));
}
OpenPOWER on IntegriCloud