hashids 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +4 -0
- data/lib/hashids.rb +6 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bcf921c95958fac763731852a7bada447d74e30f
|
4
|
+
data.tar.gz: 6f6c71145d00140152c127e0978c28966fc30fe1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6170e1679f92a5590f4a64c9350dd64bbca1518725726ef0340bd375c6c5f71779bf80b7dfd043e78b3c70ee00075376fcab13e57645ef36e45ec48efb9da154
|
7
|
+
data.tar.gz: b3baeb0247049a60da810b66206f44018923b248cf511451239053a0ec8f1c35d39e9ff0e71f5eb6c57ea0d6cd1ff1bccbab6e3806d0bbe9c9b2e2c2f720d602
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
data/lib/hashids.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
class Hashids
|
4
|
-
VERSION = "1.0.
|
4
|
+
VERSION = "1.0.4"
|
5
5
|
|
6
6
|
MIN_ALPHABET_LENGTH = 16
|
7
7
|
SEP_DIV = 3.5
|
@@ -142,24 +142,21 @@ class Hashids
|
|
142
142
|
|
143
143
|
def consistent_shuffle(alphabet, salt)
|
144
144
|
return alphabet if salt.nil? || salt.empty?
|
145
|
-
|
146
145
|
v = 0
|
147
146
|
p = 0
|
148
|
-
|
147
|
+
chars = alphabet.chars.to_a
|
148
|
+
slen = salt.length
|
149
149
|
(alphabet.length-1).downto(1) do |i|
|
150
|
-
v = v %
|
150
|
+
v = v % slen
|
151
151
|
p += n = salt[v].ord
|
152
152
|
j = (n + v + p) % i
|
153
153
|
|
154
|
-
|
155
|
-
|
156
|
-
alphabet = alphabet[0, j] + alphabet[i] + alphabet[j + 1..-1]
|
157
|
-
alphabet = alphabet[0, i] + tmp_char + alphabet[i + 1..-1]
|
154
|
+
chars[i], chars[j] = chars[j], chars[i]
|
158
155
|
|
159
156
|
v += 1
|
160
157
|
end
|
161
158
|
|
162
|
-
|
159
|
+
chars.join
|
163
160
|
end
|
164
161
|
|
165
162
|
def hash(input, alphabet)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hashids
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Hellberg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Use hashids when you do not want to expose your database ids to the user.
|
14
14
|
email:
|