Sign in to follow this  
Followers 0
MSLx Fanboy

cryptdll.dll

4 posts in this topic

I'm trying to do a hash function in AutoIt, but since it isn't implemented *yet* (*wink*), I was wondering if someone could give me an example on how to use the MD5 functions in the cryptdll.dll file. I've looked all over the place, found the 3 functions (MD5Init, MD5Update, MD5Final), but I don't know how to use them.

Any help would be greatly appreciated!


Writing AutoIt scripts since
_DateAdd("d", -2, _NowCalcDate())

Share this post


Link to post
Share on other sites



Hello,

I have never used this dll, but I have used the C implementation extract from the rfc 1321.

to make a md5 with a string :

/* Digests a string and prints the result.
 */
static void MDString (string)
char *string;
{
  MD_CTX context;
  unsigned char digest[16];
  unsigned int len = strlen (string);

  MDInit (&context);
  MDUpdate (&context, string, len);
  MDFinal (digest, &context);

  printf ("MD%d (\"%s\") = ", MD, string);
  MDPrint (digest);
  printf ("\n");
}

and for a file :

/* Digests a file and prints the result.
*/
static void MDFile (filename)
char *filename;
{
  FILE *file;
  MD_CTX context;
  int len;
  unsigned char buffer[1024], digest[16];

  if ((file = fopen (filename, "rb")) == NULL)
 printf ("%s can't be opened\n", filename);

  else {
 MDInit (&context);
 while (len = fread (buffer, 1, 1024, file))
   MDUpdate (&context, buffer, len);
 MDFinal (digest, &context);

 fclose (file);

 printf ("MD%d (%s) = ", MD, filename);
 MDPrint (digest);
 printf ("\n");
  }
}

So, if you call this dll with this order, i think you will success.

I hope i'll help you


Share this post


Link to post
Share on other sites

So for the string, *string is the input string, pass the context to MDInit, then, send context, string and its length to MDUpdate, and then set digest variable through MDFinal where the settings (context) is how to format it?

Hello,

    I have never used this dll, but I have used the C implementation extract from the rfc 1321.

to make a md5 with a string :

/* Digests a string and prints the result.
 */
static void MDString (string)
char *string;
{
  MD_CTX context;
  unsigned char digest[16];
  unsigned int len = strlen (string);

  MDInit (&context);
  MDUpdate (&context, string, len);
  MDFinal (digest, &context);

  printf ("MD%d (\"%s\") = ", MD, string);
  MDPrint (digest);
  printf ("\n");
}

and for a file :

/* Digests a file and prints the result.
*/
static void MDFile (filename)
char *filename;
{
  FILE *file;
  MD_CTX context;
  int len;
  unsigned char buffer[1024], digest[16];

  if ((file = fopen (filename, "rb")) == NULL)
 printf ("%s can't be opened\n", filename);

  else {
 MDInit (&context);
 while (len = fread (buffer, 1, 1024, file))
   MDUpdate (&context, buffer, len);
 MDFinal (digest, &context);

 fclose (file);

 printf ("MD%d (%s) = ", MD, filename);
 MDPrint (digest);
 printf ("\n");
  }
}

So, if you call this dll with this order, i think you will success.

I hope i'll help you

<{POST_SNAPBACK}>


Writing AutoIt scripts since
_DateAdd("d", -2, _NowCalcDate())

Share this post


Link to post
Share on other sites

how to format it?

I think it's the big work (I don't know if it's possible with Autoit ... :) )

the context is a structure :

/* MD5 context. */
typedef struct {
  UINT4 state[4];                                  /* state (ABCD) */
  UINT4 count[2];       /* number of bits, modulo 2^64 (lsb first) */
  unsigned char buffer[64];                      /* input buffer */
} MD5_CTX;

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0