Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defun generate-passphrase ()
- "Generate a passphrase from the given text in buffer."
- (interactive)
- (let ((words-hash (make-hash-table :test 'equal :size 6000)))
- (save-excursion
- (goto-char (point-min))
- (while (re-search-forward "\\w+" (point-max) t)
- (let ((word (downcase (match-string 0))))
- (if (= 0 (gethash word words-hash 0))
- (puthash word 1 words-hash))
- word)))
- (let ((words '())
- (phrase '()))
- (maphash (lambda (x y) (push x words)) words-hash)
- (dotimes (n 7 phrase)
- (setq phrase (cons (nth (random (length words)) words)
- phrase)))
- (message "%S %S words" phrase (length words)))))
Add Comment
Please, Sign In to add comment