/* md5sum BSD ver by LucySoft restricted to pass only gen */

typedef unsigned long word32;

#include <stdio.h>
#include "md5.h"
#include "getput.h"


int main(int argc, char* argv[])
{
  char md5passwd[33];
  struct MD5Context md;
  unsigned char md5buffer[32];
  int i;
  char* pass;

  if (argc != 2)
  {
  	fprintf(stderr, "usage : %s password", argv[0]);
  	return(0);
  }
  
  pass = argv[1];

  MD5Init(&md);
  MD5Update(&md, pass, strlen(pass));
  MD5Final(md5buffer, &md);
  for (i = 15; i >= 0; i--)
  {
    md5buffer[i*2+1] = (md5buffer[i] & 0xf) + '0';
    md5buffer[i*2] = (md5buffer[i] >> 4) + '0';
  }
  
  for (i = 0; i < 32; i++)
    if( md5buffer[i] > '9' )
      md5buffer[i] += 0x27; /* lower case hexa chars */
 
  fprintf(stdout, "%s \"%s\"\n", md5buffer, pass);
}


