Permalink
Browse files

Ignore planet, use our own crc32.

  • Loading branch information...
dchest committed Nov 25, 2010
1 parent f5ca81f commit f4858d74f7ffd0b9d47473b20cff0bbeedb1f6c5
Showing with 13 additions and 1 deletion.
  1. +13 −1 crc32.rkt
View
@@ -1,6 +1,17 @@
#lang racket
(require (planet untyped/unlib/crc))
; -- Taken from unlib/crc, under LGPL
; http://planet.racket-lang.org/display.ss?package=unlib.plt&owner=untyped
(define (crc32 data)
(bitwise-xor
(for/fold ([accum #xFFFFFFFF])
([byte (in-bytes data)])
(for/fold ([accum (bitwise-xor accum byte)])
([num (in-range 0 8)])
(bitwise-xor (quotient accum 2)
(* #xEDB88320 (bitwise-and accum 1)))))
#xFFFFFFFF))
(define (string->crc32 s)
(crc32 (string->bytes/utf-8 s)))
@@ -12,6 +23,7 @@
(number->hex-string (string->crc32 s)))
(provide/contract
[crc32 (-> bytes? natural-number/c)]
[string->crc32 (-> string? natural-number/c)]
[number->hex-string (-> number? any/c)]
[string->crc32/hex (-> string? any/c)])

0 comments on commit f4858d7

Please sign in to comment.