source: project/release/4/md5/trunk/md5.scm @ 34380

Last change on this file since 34380 was 34380, checked in by kon, 8 months ago

add raw-update

File size: 1.2 KB
Line 
1;;
2;; md5 - Scheme wrapper for Colin Plumb's Public Domain md5 implementation
3;;
4;; All code in this egg is in the Public Domain
5(module md5
6  (md5-primitive)
7
8(import chicken scheme foreign)
9(use message-digest-primitive)
10
11#>#include "md5-base.c"<#
12;#>#include "md5-ssl.c"<# ;an alternative coding
13
14(define digest-length (foreign-value "MD5_DIGEST_SIZE" unsigned-int))
15(define block-length (foreign-value "MD5_BLOCK_SIZE" unsigned-int))
16(define context-size (foreign-value "sizeof(struct MD5Context)" unsigned-int))
17
18(define init (foreign-lambda void MD5Init c-pointer))
19(define update (foreign-lambda void MD5Update c-pointer scheme-pointer unsigned-int))
20(define final (foreign-lambda void MD5Final c-pointer scheme-pointer))
21(define raw-update (foreign-lambda void MD5Update c-pointer c-pointer unsigned-int))
22
23(define md5-primitive
24  (let ((the-md5-primitive #f))
25    (lambda ()
26      (unless the-md5-primitive
27        (set! the-md5-primitive
28              (make-message-digest-primitive context-size digest-length
29                                             init update final
30                                             block-length 'md5-primitive
31                                             raw-update)) )
32      the-md5-primitive ) ) )
33)
Note: See TracBrowser for help on using the repository browser.