Created
November 30, 2016 02:39
-
-
Save etyurkin/00ef85a2bbcc1b764dc75553b1759a70 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; hash-pass http://hashapass.com/ | |
(defvar hash-pass-password-wait-time "30 sec" | |
"The default period to wait before erasing the password from the clipboard. | |
Must be compatible with `run-at-time'.") | |
(defun string->clipboard (string) | |
"Copy STRING to system clipboard." | |
(funcall interprogram-cut-function string)) | |
(defun hash-pass () | |
"Generate strong password based on parameter and master password." | |
(interactive) | |
(let ((param (read-string "parameter: ")) | |
(password (read-passwd "master password: "))) | |
(string->clipboard (trim | |
(shell-command-to-string | |
(format "echo -n %s | openssl dgst -sha1 -binary -hmac %s | openssl enc -base64 | cut -c 1-8" param password)))) | |
(run-at-time hash-pass-password-wait-time nil (lambda () (string->clipboard ""))) | |
(message "Generated hash has been copied to clipboard"))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment