shastr.c:


#include <stdio.h>
#include <string.h>

#include "environ.h"
#include "sha.h"

static sha_digest mydigest;
int temp;

main (argc, argv)
  int argc;
  char *argv[];
{
  int loop;
  int argument;

  /* debugging input
     printf ("DEBUG: argc = %d\n", argc);
     for (temp=0;temp<argc;temp++)printf("DEBUG: %d: (%3d) %s\n", temp, strlen(argv[temp]), argv[temp]);
  */
  if (argc < 2) {
     printf ("Usage:  SHSstring text\n");
     return 1;
  }
  
  argument = 1;
  while (argument < argc) {
     /* Do the work */
     shaInit   (NULL, 1);
     shaUpdate (NULL, (BITS8 *) argv[argument], strlen (argv[argument]));
     shaFinal  (NULL, mydigest);
  
     /* print it out. */
      for (loop=0; loop<SHF_DIGESTSIZE; loop++) printf ("%02lX", mydigest[loop]);
      printf ("\n");
  
     argument ++;
  }
  
  return 0;
}

Go to ...


This page is http://www.cc.utah.edu/~nahaj/c/sha/shastr.c.html
© Copyright 2000 by John Halleck, All Rights Reserved.
This snapshot was last modified on August 23rd, 2000
And the underlying file was last modified on May 30th, 2000