Changeset 36182 in project


Ignore:
Timestamp:
08/11/18 21:31:27 (12 months ago)
Author:
sjamaan
Message:

Drop srfi-13 dependency from simple-sha1, because it worked for simple-md5 too

Location:
release/5/simple-sha1/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/5/simple-sha1/trunk/simple-sha1.egg

    r36047 r36182  
    55 (license "Public Domain")
    66 (maintainer "felix winkelmann")
    7  (dependencies memory-mapped-files srfi-13)
     7 (dependencies memory-mapped-files)
    88 (test-dependencies test)
    99 (category crypt)
  • release/5/simple-sha1/trunk/simple-sha1.scm

    r35696 r36182  
    99(module simple-sha1 (sha1sum string->sha1sum)
    1010
    11 (import scheme chicken.base chicken.file chicken.file.posix chicken.foreign)
     11(import scheme chicken.base chicken.fixnum chicken.file chicken.file.posix chicken.foreign)
    1212(import chicken.memory memory-mapped-files)
    13 (import srfi-13)
    1413
    15 #>
    16 #include "sha1-base.c"
    17 #include <unistd.h>
    18 <#
     14(foreign-declare "#include \"sha1-base.c\"")
     15(foreign-declare "#include <unistd.h>")
    1916
    2017;;
     
    2825(define-constant digest-length 20)
    2926
     27(define (char->hexdigits c)
     28  (let ((int (char->integer c)))
     29    (if (fx>= int 16)
     30        (number->string int 16)
     31        (string-append "0" (number->string int 16)))))
     32
    3033(define (string->sha1sum str)
    3134  (let* ((str-size (string-length str))
     
    3740    (finish ctxt digest)
    3841    (free ctxt)
    39     (string-concatenate
    40      (map (lambda (c)
    41             (string-pad (number->string (char->integer c) 16) 2 #\0))
    42           (string->list digest)))))
     42    (apply string-append (map char->hexdigits (string->list digest)))))
    4343
    4444(cond-expand
     
    7777         (free ctxt)
    7878         (file-close fd)
    79          (string-concatenate
    80           (map (lambda (c)
    81                  (string-pad (number->string (char->integer c) 16) 2 #\0))
    82                (string->list digest))))))
     79         (apply string-append (map char->hexdigits (string->list digest))))))
    8380
    8481)
Note: See TracChangeset for help on using the changeset viewer.