diff --git a/hashids.janet b/hashids.janet index e5284d9..78a87d1 100644 --- a/hashids.janet +++ b/hashids.janet @@ -20,7 +20,7 @@ (var p 0) (loop [i :down [(- (length alph-bytes) 1) 0]] - (let [v (mod i (length salt-bytes)) + (let [v (mod (- (length alph-bytes) i 1) (length salt-bytes)) n (get salt-bytes v)] (set p (+ p n)) (def j (mod (+ n v p) i)) diff --git a/test/consistent-shuffle.janet b/test/consistent-shuffle.janet index 647394e..0781104 100644 --- a/test/consistent-shuffle.janet +++ b/test/consistent-shuffle.janet @@ -14,5 +14,13 @@ (assert (= "cadb" (h/consistent-shuffle "abcd" salt))) +(assert + (= "f17a8zvCwo0iuqYDXlJ4RmAS2end5ghTcpjbOWLK9GFyE6xUI3ZBMQtPsNHrkV" + (h/consistent-shuffle "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890" + "salt"))) + + + + \ No newline at end of file