Re: MD5 algorithm

From: Wojtek Walczak (gminick@hacker.pl)
Date: 03/29/02


From: gminick@hacker.pl (Wojtek Walczak)
Date: Fri, 29 Mar 2002 12:37:14 +0000 (UTC)


** Since micro$oft is stupid it doesn't mean
** that you should be stupid too - do NOT toppost.
Dnia 28 Mar 2002 02:57:49 -0800, dwij napisał(a):
>main()
>{
> const unsigned char *d = "password";
> unsigned char *md;
> unsigned long n;
> MD5_CTX *c;
> MD5_Init(c);
> MD5_Final(md,c);
> md = (unsigned char *)malloc(100);
> MD5(d,n,md);
> printf("%s",md);
>}
ufff... your code was hard to debug ;)
even now i'm not sure if it works properly(looks like it's not)
(because i haven't been using openssl for a year or so...)
your code after a little modification looks like:

---
#include <stdio.h>
#include <openssl/md5.h>
#include <stdlib.h>
int main(void)
{
        const unsigned char *d = "password";
        unsigned char md[1000];
        unsigned long n;
        MD5_CTX c;

MD5_Init(&c); MD5_Final(md,&c); MD5(d,n,md); printf("%x\n",md); return 0; } ---

and to compile it you should use that command (works on slack8.0):

gcc -Wall md5.c -lssl

with openssl headers installed

if you can, use (i.e.)Python instead of C, it's a lot nicer, simple example:

--- #!/usr/local/bin/python import md5 m = md5.new() m.update("password") print m.hexdigest() ---

HTH

-- [ Wojtek gminick Walczak ][ http://hacker.pl/gminick/ ] [ gminick (at) hacker.pl ][ gminick (at) klub.chip.pl ]



Relevant Pages

  • Re: subroutine stack and C machine model
    ... give a warning about something being outside array bounds from gcc. ... I'm not sure whether it's 100% stupid or not, ... that you really don't care about, followed by some amount of data ... Dimension the data as unsigned char ...
    (comp.lang.c)
  • Re: Prevent SSH Version Info?
    ... ** that you should be stupid too - do NOT toppost ... > mearly bitch about top posting....save your breath/don't waist the ... try to read a top-posted and not correctly cut thread at ...
    (comp.os.linux.security)
  • Re: tcp port 0
    ... ** that you should be stupid too - do NOT toppost. ... I wanted to translate it but I haven't got time to do it. ... take a look at www.linuxdoc.org and their 'Linux Ext2fs Undeletion ...
    (comp.os.linux.security)
  • Re: FTP and chroot for ftp clients
    ... ** that you should be stupid too - do NOT toppost. ... >How can I setup a client so that no matter what machine they login with they ... >seems to work from a command line but not a ftp client like wsftp. ...
    (comp.security.unix)
  • Re: Camera Raw plug-ins
    ... Zilla wrote: ... Because it's stupid to read an answer before you've read the question ... Why shouldn't I toppost? ... Editor / Photographer http://www.johanfoto.com ...
    (comp.graphics.apps.photoshop)