Welcome to the CHICKEN Scheme pasting service
use of urandom from knodium-sessions pasted by andyjpb on Tue Jul 16 16:26:33 2019
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Randomness ; really random but blocks ;(make-entropy-source-random-device) ; not so random but doesn't block ;(make-entropy-source-urandom-device) (define (make-secret-generator) (let ((source (make-entropy-source-urandom-device))) (lambda (byte-width) (u8vectors->base64 (entropy-source-u8vector source byte-width))))) (define get-cid-secret (make-secret-generator)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
base64 helpers added by andyjpb on Tue Jul 16 16:34:06 2019
(define (u8vectors->base64 . vecs) (if (= 1 (length vecs)) (base64-encode (blob->string (u8vector->blob/shared (car vecs)))) (u8vectors->base64 (list->u8vector (flatten (map u8vector->list vecs)))))) (define (base64->u8vectors str . subu8ranges) (let ((vec (blob->u8vector (string->blob (base64-decode str))))) (if (> (length subu8ranges) 0) (apply values (map (lambda (x) (subu8vector vec (car x) (cadr x))) subu8ranges)) vec)))