From e2f13a1c58cc6049f477d1d27a7c334f735d4ef1 Mon Sep 17 00:00:00 2001 From: jdormit Date: Mon, 8 Apr 2024 23:34:24 -0400 Subject: [PATCH] Add urandom function --- emacs/.emacs.d/config/init-lib.el | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/emacs/.emacs.d/config/init-lib.el b/emacs/.emacs.d/config/init-lib.el index 3784768..ce0b693 100644 --- a/emacs/.emacs.d/config/init-lib.el +++ b/emacs/.emacs.d/config/init-lib.el @@ -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)