~statianzo/janet-hashids

827f9d17421a00f6bd17cebad5cc72fd666ccb82 — Jason Staten 4 years ago 55277cd
shufflin correctly
2 files changed, 9 insertions(+), 1 deletions(-)

M hashids.janet
M test/consistent-shuffle.janet
M hashids.janet => hashids.janet +1 -1
@@ 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))

M test/consistent-shuffle.janet => test/consistent-shuffle.janet +8 -0
@@ 14,5 14,13 @@
(assert
  (= "cadb" (h/consistent-shuffle "abcd" salt)))

(assert
  (= "f17a8zvCwo0iuqYDXlJ4RmAS2end5ghTcpjbOWLK9GFyE6xUI3ZBMQtPsNHrkV"
     (h/consistent-shuffle "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
                           "salt")))





  
\ No newline at end of file