Welcome to the CHICKEN Scheme pasting service

not a non immediate? added by dsp on Fri Apr 17 10:15:30 2020

(import (chicken base))
(import (chicken foreign))
(import crypto-tools)
(import format)

(define (make-next-ctr bsize)
          (lambda (iv)
            (let ((origiv '()))
              (if (null? origiv)
                (set! origiv iv))
                  (let* ((cnt origiv)
                         (ocnt cnt)
                         (ncnt ((foreign-lambda* void ((blob in) (int blocksize)) "
                                     char cur;
                                     int block;
                                     for(block=blocksize-1;block>=0;block--) {
                                          cur = in[block];
                                          if (cur >= 255) {
                                                in[block] = 0;
                                                continue;
                                          }
                                          in[block] = cur+1;
                                          break;
                                     }
                                  ") cnt bsize)))
                      (set! cnt ncnt)
                      ocnt))))


(define iv (make-next-ctr 16))

(format "starts:~A~%" (iv (hexstring->blob "0000000000000000")))
(format "it is:~A~%" (iv 0))
(format "it is:~A~%" (iv 0))
(format "it is:~A~%" (iv 0))
(format "it is:~A~%" (iv 0))
(format "it is:~A~%" (iv 0))
(format "it is:~A~%" (iv 0))

Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
Which backend storage does qwiki use?
Visually impaired? Let me spell it for you (wav file) download WAV