2021-05-26 12:37:49 +00:00
|
|
|
#lang racket/base
|
2021-06-04 14:20:14 +00:00
|
|
|
;;; SPDX-License-Identifier: LGPL-3.0-or-later
|
2022-01-16 08:48:18 +00:00
|
|
|
;;; SPDX-FileCopyrightText: Copyright © 2019-2022 Tony Garnock-Jones <tonyg@leastfixedpoint.com>
|
2021-05-26 12:37:49 +00:00
|
|
|
|
|
|
|
(provide strong-gensym)
|
|
|
|
|
|
|
|
(require (only-in net/base64 base64-encode))
|
|
|
|
(require (only-in racket/random crypto-random-bytes))
|
|
|
|
(require (only-in racket/string string-trim))
|
|
|
|
|
|
|
|
(define (strong-gensym [head 'g] #:random-bytes [count 16])
|
|
|
|
(string->symbol
|
|
|
|
(format "~a~a"
|
|
|
|
head
|
|
|
|
(string-trim (bytes->string/latin-1
|
|
|
|
(base64-encode (crypto-random-bytes count) #""))
|
|
|
|
#px"=+"))))
|