PasteRack.org
Paste # 3106
2020-10-15 10:33:35

Fork as a new paste.

Paste viewed 266 times.


Embed:

  1. #lang racket
  2.  
  3. (define (cloudflare-email-decode hex-string)
  4.   (define k (string->number (substring hex-string 0 2) 16))
  5.   (define (loop hx-str decoded-str)
  6.     (cond [(empty-string? hx-str) decoded-str]
  7.           [else (define b (string->number (substring hx-str 0 2) 16))
  8.                 (define d (string (integer->char (bitwise-xor k b))))
  9.                 (loop (substring hx-str 2)
  10.                       (string-append decoded-str d))]))
  11.   (loop (substring hex-string 2) ""))
  12.  
  13.  
  14. (cloudflare-email-decode "d8b0beb0b3bbb7b098bbbdb6acadaaa1b4b1b6b3f6b6bdac")

=>

empty-string?: undefined;

 cannot reference an identifier before its definition

  in module: 'm