2 ** Copyright 2000 Double Precision, Inc.
3 ** See COPYING for distribution information.
9 static const char rcsid
[]="$Id: md5_hash.c,v 1.5 2002/12/12 04:23:58 mrsam Exp $";
11 static const char base64tab
[]=
12 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
14 const char *md5_hash_courier(const char *passw
)
17 static char hash_buffer
[1+(sizeof(md5buf
)+2)/3*4];
22 md5_digest(passw
, strlen(passw
), md5buf
);
26 for (i
=0; i
<sizeof(md5buf
); i
+= 3)
29 b
= i
+1 < sizeof(md5buf
) ? md5buf
[i
+1]:0;
30 c
= i
+2 < sizeof(md5buf
) ? md5buf
[i
+2]:0;
32 d
=base64tab
[ a
>> 2 ];
33 e
=base64tab
[ ((a
& 3 ) << 4) | (b
>> 4)];
34 f
=base64tab
[ ((b
& 15) << 2) | (c
>> 6)];
35 g
=base64tab
[ c
& 63 ];
36 if (i
+ 1 >= sizeof(md5buf
)) f
='=';
37 if (i
+ 2 >= sizeof(md5buf
)) g
='=';