hashids 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.travis.yml +6 -5
- data/README.md +6 -1
- data/lib/hashids.rb +10 -9
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bd2447b35dec96410f58a8c4e09c8ca71b1d82be3085c31a47ff15925ba25c48
|
4
|
+
data.tar.gz: 19bc31151f60ecb16d435d27c5dd729d5916105b78e428e20abf03a721d243d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f65cde7092f2495f0cbcbdd91e49b694eadccbb28c8ef544cf118ce3ac152bc87cd6cfc7544aaf82b24cef59fb6ae4ea2bd87fb66a001107ab46ed0b751e58f1
|
7
|
+
data.tar.gz: 617de24d05f872da30cfb701327e4cf45bb8cee856190e648df5e156bf753697c88c1ce53c23dabc1be60d0eaaeadc98a8b82c5319836d637bf367a64fbbb9e9
|
data/.travis.yml
CHANGED
@@ -3,12 +3,13 @@ language: ruby
|
|
3
3
|
bundler_args: --without documentation
|
4
4
|
|
5
5
|
rvm:
|
6
|
-
- 2.
|
7
|
-
- 2.
|
8
|
-
- 2.
|
6
|
+
- 2.5.1
|
7
|
+
- 2.4.5
|
8
|
+
- 2.3.8
|
9
|
+
- 2.2.10
|
9
10
|
- 2.1.10
|
10
11
|
- 2.0.0
|
11
|
-
- jruby-9.1.
|
12
|
-
- jruby-1.7.
|
12
|
+
- jruby-9.1.17.0
|
13
|
+
- jruby-1.7.27
|
13
14
|
|
14
15
|
sudo: false
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@ Use hashids when you do not want to expose your database ids to the user.
|
|
6
6
|
[http://hashids.org/ruby/](http://hashids.org/ruby/)
|
7
7
|
|
8
8
|
[](http://travis-ci.org/peterhellberg/hashids.rb)
|
9
|
-
(2.4.
|
9
|
+
(2.5.1, 2.4.5, 2.3.8, 2.2.10, 2.1.10, 2.0.0, jruby-9.1.17.0, jruby-1.7.27)
|
10
10
|
|
11
11
|
## What is it?
|
12
12
|
|
@@ -208,6 +208,11 @@ hex_str = hashids.decode_hex("kRNrpKlJ")
|
|
208
208
|
|
209
209
|
## Changelog
|
210
210
|
|
211
|
+
**1.0.5**
|
212
|
+
|
213
|
+
- Improve shuffle performance
|
214
|
+
- Update rubies used by Travis-CI
|
215
|
+
|
211
216
|
**1.0.4**
|
212
217
|
|
213
218
|
- Improved encode/decode performance
|
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.5"
|
5
5
|
|
6
6
|
MIN_ALPHABET_LENGTH = 16
|
7
7
|
SEP_DIV = 3.5
|
@@ -142,18 +142,19 @@ class Hashids
|
|
142
142
|
|
143
143
|
def consistent_shuffle(alphabet, salt)
|
144
144
|
return alphabet if salt.nil? || salt.empty?
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
145
|
+
|
146
|
+
chars = alphabet.each_char.to_a
|
147
|
+
salt_ords = salt.codepoints.to_a
|
148
|
+
salt_length = salt_ords.length
|
149
|
+
idx = ord_total = 0
|
150
|
+
|
149
151
|
(alphabet.length-1).downto(1) do |i|
|
150
|
-
|
151
|
-
|
152
|
-
j = (n + v + p) % i
|
152
|
+
ord_total += n = salt_ords[idx]
|
153
|
+
j = (n + idx + ord_total) % i
|
153
154
|
|
154
155
|
chars[i], chars[j] = chars[j], chars[i]
|
155
156
|
|
156
|
-
|
157
|
+
idx = (idx + 1) % salt_length
|
157
158
|
end
|
158
159
|
|
159
160
|
chars.join
|
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Hellberg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-11-07 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:
|
@@ -45,7 +45,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
45
45
|
version: '0'
|
46
46
|
requirements: []
|
47
47
|
rubyforge_project:
|
48
|
-
rubygems_version: 2.
|
48
|
+
rubygems_version: 2.7.7
|
49
49
|
signing_key:
|
50
50
|
specification_version: 4
|
51
51
|
summary: Generate YouTube-like hashes from one or many numbers.
|