You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
623 B

(import ../hashids :as h)
(defn string-shuffle [alph salt]
(apply string/from-bytes
(h/consistent-shuffle (string/bytes alph)
(string/bytes salt))))
(def salt "this is my salt")
(assert
(= "abc" (string-shuffle "abc" "")))
(assert
(= "ba" (string-shuffle "ab" salt)))
(assert
(= "bca" (string-shuffle "abc" salt)))
(assert
(= "cadb" (string-shuffle "abcd" salt)))
(assert
(= "f17a8zvCwo0iuqYDXlJ4RmAS2end5ghTcpjbOWLK9GFyE6xUI3ZBMQtPsNHrkV"
(string-shuffle "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
"salt")))