If you can't rely on an external service (no internet connection), you can store the hash of the password in a file of your uberjar.
; utility methods
(defn to-base64 [bytes]
(String. (.encode (java.util.Base64/getEncoder) bytes)))
; function to encrypt string formatted password
(defn encrypt-password [string]
(let [ sha (java.security.MessageDigest/getInstance "SHA")]
(.update sha (.getBytes string))
(to-base64
(.digest sha))))
; call this one time, to store the secret in encrypted form
; this would be part of your jar file, but regular users cannot
; (probably) decrypt this.
(defn save-password [ secret-password ]
(spit
"secret"
(encrypt-password secret-password)))
; use this to validate this
(defn validate-password [ input ]
(.equalsIgnoreCase
(String. (slurp "secret"))
(String. (encrypt-password input))))
Finally, you can create and check passwords with the above methods:
(save-password "hello")
(validate-password "hello")
; true
(save-password "hellome!")
(validate-password "hello")
; false