Add urandom function

This commit is contained in:
jdormit 2024-04-08 23:34:24 -04:00
parent 11319dfe20
commit e2f13a1c58

View File

@ -126,4 +126,12 @@
(use-package shut-up
:commands (shut-up))
(defun urandom (len)
"Generate a random string of length LEN using /dev/urandom."
(interactive "nLength: ")
(let ((rand (shell-command-to-string (format "head -c %d /dev/urandom | base64" len))))
(when (called-interactively-p 'any)
(kill-new (message rand)))
rand))
(provide 'init-lib)