AmendHub

Download

plus

/

MD5

/

md5pascal.c

 

(View History)

mrw   Initial commit. Latest amendment: 1 on 2024-10-15

1 #define _MD5_EXPLICIT_INIT 1
2
3 #include "md5c.c"
4
5 /* Pascal interface
6 It's easier to define Pascal functions in THINK C than
7 it is to call C functions from THINK Pascal
8 */
9
10 /* THINK Pascal < 4 doesn't load libraries' DATA resources.
11 Call this function once to initialize global state, but
12 only if you need it!
13 */
14 pascal void InitLibP()
15 {
16 PADDING = (unsigned char *) NewPtrClear(64);
17 PADDING[0] = 0x80;
18 }
19
20 #ifdef _MD5_EXPLICIT_INIT
21 /* MD5InitP - initialize the MD5 context
22 */
23 pascal void MD5InitP(MD5_CTX *ctx)
24 {
25 MD5Init(ctx);
26 }
27 #endif
28
29 /* MD5UpdateP - update an MD5 digest with a Str255
30 This doesn't use pascal.h because that would insert a
31 null byte.
32 */
33 pascal void MD5UpdateP(MD5_CTX *ctx, unsigned char *input)
34 {
35 int len = (int) *input++;
36 MD5Update(ctx, input, len);
37 }
38
39 /* MD5Final - finalize an MD5 context, retrieving the
40 digest into a Str255.
41 This doesn't use pascal.h because that would expect a
42 null byte to indicate length.
43 */
44 pascal void MD5FinalP(unsigned char *digest, MD5_CTX *ctx)
45 {
46 *(digest++) = 16;
47 MD5Final(digest, ctx);
48 }