Re: [racket-dev] hex decoding?

2013-09-04 Thread David Vanderson
Sorry it took so long, but I've submitted a pull request to make this function public in file/sha1: https://github.com/plt/racket/pull/426 Let me know if I screwed up, it's my first pull request. Thanks, Dave On 06/11/2013 05:11 PM, Robby Findler wrote: Yes, I think file/sha1 is the right pl

Re: [racket-dev] hex decoding?

2013-06-11 Thread Robby Findler
Yes, I think file/sha1 is the right place. Thanks! Robby On Tue, Jun 11, 2013 at 3:26 PM, David Vanderson wrote: > Thank you Stephen and Tony for your examples. I found the following > private function in db/private/mysql/connection.**rkt: > > (define (hex-string->bytes s) > (define (hex-di

Re: [racket-dev] hex decoding?

2013-06-11 Thread Matthias Felleisen
Sorry all I am saying the creator of db/private/mysql/connection.rkt didn't anticipate your needs and kept the function private. If you want to submit a pull request to move this function to db or db/base (including an appropriate provide), please do so. On Jun 11, 2013, at 4:41 PM, David

Re: [racket-dev] hex decoding?

2013-06-11 Thread David Vanderson
On 06/11/2013 04:33 PM, Matthias Felleisen wrote: db/private/mysql/connection.rkt does not export the function, otherwise you could. I don't understand this. I'd like to make the function available to users somewhere - are you saying that's bad? On Jun 11, 2013, at 4:26 PM, David Vanders

Re: [racket-dev] hex decoding?

2013-06-11 Thread Matthias Felleisen
db/private/mysql/connection.rkt does not export the function, otherwise you could. On Jun 11, 2013, at 4:26 PM, David Vanderson wrote: > Thank you Stephen and Tony for your examples. I found the following private > function in db/private/mysql/connection.rkt: > > (define (hex-string->byt

Re: [racket-dev] hex decoding?

2013-06-11 Thread David Vanderson
Thank you Stephen and Tony for your examples. I found the following private function in db/private/mysql/connection.rkt: (define (hex-string->bytes s) (define (hex-digit->int c) (let ([c (char->integer c)]) (cond [(<= (char->integer #\0) c (char->integer #\9)) (- c (cha

Re: [racket-dev] hex decoding?

2013-06-10 Thread Tony Garnock-Jones
Here's the one I've been using in racl (https://github.com/tonyg/racl, raco pkg install racl). It ignores non-hex characters but is less efficient than Stephen's version. Um, and it expects *bytes* as input, not strings. I'm not sure why, actually. (define (hex-string->bytes . strs) (define cle

Re: [racket-dev] hex decoding?

2013-06-09 Thread Stephen Chang
There doesn't appear to be a library function for going the reverse direction but here's one way to write it up: #lang racket (define ASCII-ZERO (char->integer #\0)) ;; [0-9A-Fa-f] -> Number from 0 to 15 (define (hex-char->number c) (if (char-numeric? c) (- (char->integer c) ASCII-ZERO)

[racket-dev] hex decoding?

2013-06-09 Thread David Vanderson
I'm doing some cryptography exercises that involve a lot of hex encoding/decoding. I see there's a bytes->hex-string function in file/sha1 and openssl/sha1, but I can't find a decode function. Is a hex decode function in the distribution? Thanks, Dave _ Racket Develop