token_checksum 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 14d770b16d0d2063bd7fccb11c4d6a2c6fd748545ffe08cb7a6f66a5fcbcd0da
4
- data.tar.gz: 350aaaff96ae975c1e727bdabb987bcb34c610b6249bb2398c173ee12d5d51f9
3
+ metadata.gz: 35778c0c9930ef13a6ac8031d9e062ba7743448ecbd41688fc4d23285c28090e
4
+ data.tar.gz: 136963fe3894f9fd3aab73329ed6156404ef656551083706c7dc30ef59b1d616
5
5
  SHA512:
6
- metadata.gz: cd520256bd3f79799296f298fe3d074ac698df8cb8a834d75aa9c70148fb2217a286246a5bad46488fe593f2455a8a54a6aa5ae103774704ac9cfff5688de121
7
- data.tar.gz: f2130b655f599decab22827b6519f792211bae0d057a51905377cc0a6097502b224b8cf3ee5caf2d80d5ef0f9aeddb10c6ab9885e2526c2a655e66fdf3b1cd9b
6
+ metadata.gz: 87107d68ddbcc35b987ca39b76e369932bb5b670d56f7638773d6770432eb4a0cd55e39c6e6c7644939c0661de7489b0d18fd9335a9fb4349f822898d75645d9
7
+ data.tar.gz: f93b72fdd81da6fb06aac30fefe81c9192e125725ce0b9d23878d328e53872067986cfe6144ac85d5e34907c0aa5956c25aff622af2c635cffb0f22d4e01be6a
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # TokenChecksum
2
2
 
3
- Generates a 37 character long random token, with an (optional) prefix and a 32-bit checksum in the last 6 digits. Inspired by:
3
+ Generates a 30 character long random token, with a prefix and a 32-bit checksum in the last 6 digits. Inspired by:
4
4
 
5
5
  * https://github.blog/2021-04-05-behind-githubs-new-authentication-token-formats/
6
6
  * https://github.com/stefansundin/token-checksum
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TokenChecksum
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
@@ -12,6 +12,8 @@ if ENV.fetch("DEBUG", "false")
12
12
  end
13
13
 
14
14
  module TokenChecksum
15
+ REGEX = /([abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]{1,})_([0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]{30})([0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]{6})/
16
+
15
17
  class << self
16
18
  def generate(prefix, secret: "")
17
19
  suffix = (random_base62 + random_base62)[0...30]
@@ -41,7 +43,7 @@ module TokenChecksum
41
43
  end
42
44
 
43
45
  private def random_base62
44
- Base62.encode(SecureRandom.uuid.delete("-").hex)
46
+ Base62.encode(SecureRandom.uuid.delete("-").to_i(16))
45
47
  end
46
48
  end
47
49
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: token_checksum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen J. Torikian
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-30 00:00:00.000000000 Z
11
+ date: 2022-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: securecompare