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)))

Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
Type in the text below:
       _                               
 _   _| |____  ____ _ _ __  _ __   ___ 
| | | | '_ \ \/ / _` | '_ \| '_ \ / __|
| |_| | |_) >  < (_| | |_) | | | | (__ 
 \__,_|_.__/_/\_\__,_| .__/|_| |_|\___|
                     |_|               
Visually impaired? Let me spell it for you (wav file) download WAV