io.randomseed.utils.crypto
added in 1.0.0
Random utilities, crypto support functions.
ask-key
(ask-key & {:as opts})
Ask user for a key with confirmation. Repeats until two keys are the same and are not empty. Keyword arguments can be given to configure behavior: prompt
(message displayed when asking for first key), confirm-prompt
(message displayed when asking for the same key again), not-match-msg
(message displayed when keys do not match), empty-msg
(message displayed when the entered key is empty), retries
(number of retries before quitting the loop; when set to nil
or not given, it will continue indefinitely), confirmation?
(requires key to be re-entered for confirmation, defaults to true
), allow-empty?
(allows the entered key to be an empty string; defaults to false
), empty-nil?
(returns nil
instead of an empty string when on empty key; defaults to false
), empty-quits?
(short-circuits on any empty key and returns nil
; defaults to false
), empty-quits-nil?
(returns nil
when quitting on empty key; defaults to true
). Returns the entered key or nil
.
ask-pass
(ask-pass & {:as opts})
Ask user for a password with confirmation. Repeats until two passwords are the same and are not empty. Keyword arguments can be given to configure behavior: prompt
(message displayed when asking for first password), confirm-prompt
(message displayed when asking for the same password again), not-match-msg
(message displayed when passwords do not match), empty-msg
(message displayed when the entered password is empty), retries
(number of retries before quitting the loop; when set to nil
or not given, it will continue indefinitely), confirmation?
(requires password to be re-entered for confirmation, defaults to true
), allow-empty?
(allows the entered password to be an empty string; defaults to false
), empty-nil?
(returns nil
instead of an empty string when on empty password; defaults to false
), empty-quits?
(short-circuits on any empty password and returns nil
; defaults to false
), empty-quits-nil?
(returns nil
when quitting on empty password; defaults to true
). Returns the entered password or nil
.
encrypt-key
(encrypt-key k password)
Encrypts private key using random IV and the given password. Returns base64-encoded map of two keys.