Submitted by no_defun_allowed in programming

uses ironclad cause i want hashes. makes 4 lines of 4 5-letter CVCVC words.

(use-package :ironclad)

(defvar *vowels* #(#\A #\E #\O #\U))
(defvar *consonants* #(#\B #\D #\F #\G #\H #\J #\K #\L
                       #\M #\N #\P #\R #\S #\T #\V #\Z))

(defun readable-verifier (key)
  (format nil "~{~a ~(~a ~a ~a~)~^,~%~}"
          (loop
             with digest = (digest-sequence :sha256 key)
             for n below (length digest) by 2
             for v = (+ (ash (aref digest n) 8)
                        (aref digest (1+ n)))
             collect (format nil "~c~(~c~c~c~c~)"
                             (aref *consonants*
                                   (ldb (byte 4 0) v))
                             (aref *vowels*
                                   (ldb (byte 2 4) v))
                             (aref *consonants*
                                   (ldb (byte 4 6) v))
                             (aref *vowels*
                                   (ldb (byte 2 10) v))
                             (aref *consonants*
                                   (ldb (byte 4 12) v))))))

example usage:

> (ascii-string-to-byte-array "foo")
#(102 111 111)
> (readable-verifier *)
"Kobuf roder zugok zapes,
Rekoz suheh buhud huhah,
Fatad bujuf gafek bovur,
Pakoz mapuj konak vovev"
7

Comments

You must log in or register to comment.

musou wrote

this is neat! with your permission, i am going to stash this little script in my bin folder for use when i'm running D&D and in need of a fresh magic incantation. my players are all running around thwarting cultists from alternate dimensional planes so this comes up more often than you might think.

4

no_defun_allowed OP wrote

go for it! this program is released under the "please share but no rust port pls" license

3