anchor.diff:  ;;;
   ;;; Utils
   ;;;
  -(defun hash-password (password)
  +
  +;;; The password confirmation scheme uses PDKDF2. CouchDB's randomly-generated document id for the
  +;;; particular account is used as a salt for the password. The two parameters should be adjusted
  +;;; according to your server's capabilities. Do some profiling and make these numbers as high as you
  +;;; can without lagging under heavy load.
  +
  +(defparameter *key-derivation-iterations* 1056)
  +(defparameter *key-length* 32)
  +(defun hash-password (password salt)
     "Password hashing function."
  -  ;; TODO - maybe a salt?
  +  (ironclad:byte-array-to-hex-string
  +   (ironclad:derive-key
  +    (make-instance 'ironclad:pbkdf2 :digest :sha256)
  +    (ironclad:ascii-string-to-byte-array password)
  +    (ironclad:ascii-string-to-byte-array salt)
  +    *key-derivation-iterations*
  +    *key-length*))
  +  #+nil
     (ironclad:byte-array-to-hex-string
      (ironclad:digest-sequence
       :sha256
  
positive.code: (defun find-account (account-name)
    (account-view-value "by_account_name" (string-downcase account-name)))
  
  (defun validate-credentials (account-name password &aux (hashed-pass (hash-password password)))
    (account-view-value "by_account_name_password" (list (string-downcase account-name) hashed-pass)))
  
  (defun account-name (account)
    (doc-val account "account_name"))
  
negative.code: 
  (defun valid-password-p (password)
    (and (>= (length password) 6)
         (not (find-if-not #'standard-char-p password))))
  
  (defun valid-display-name-p (display-name)
  