         (let ((digits (substring string (* 2 i) (* 2 (1+ i)))))
           (setf (aref output i) (string-to-number digits 16)))))))
 
-(defun rc4hash-verify (hash password)
+(defun rc4hash-verify (hash password &optional binary)
   "Verify HASH for given PASSWORD, returning non-nil for valid match."
-  (let ((salt (substring hash 0 4))
-        (difficulty (rc4hash-decode-uint32 (substring hash 4 8))))
-    (string= (rc4hash password difficulty salt) hash)))
+  (unless binary
+    (setf hash (rc4hash--from-hex hash)))
+  (let* ((salt (substring hash 0 4))
+         (difficulty (aref hash 4))
+         (copy (rc4hash password :difficulty difficulty :salt salt :binary t)))
+    (string= copy hash)))
 
 (provide 'rc4hash)
 

          (setf (aref output (+ 0 (* i 2))) (aref byte 0)
                (aref output (+ 1 (* i 2))) (aref byte 1)))))))

(defun rc4hash-from-hex (string)
  "Compute STRING of hexidecimal digits to a unibyte string."
  (let ((output (make-string (/ (length string) 2) 0)))
    (prog1 output

    (rc4-mix rc4 salt)
    (let* ((padsize (- 256 (length upassword)))
           (key (concat upassword (rc4-emit-n rc4 padsize))))
      (dotimes (_ (lsh 1 difficulty))
        (rc4-mix rc4 key)))
    (cl-loop repeat (* (- (lsh 1 difficulty) 1) 64) do (rc4-emit rc4))
    (let ((hash (concat salt (list difficulty) (rc4-emit-n rc4 21))))
      (if binary
          hash
        (rc4hash--to-hex hash)))))

(defun rc4hash--to-hex (hash)
  "Convert unibyte string HASH to a string of hexidecimal digits."
  (let ((output (make-string (* 2 (length hash)) 0)))
    (prog1 output
