base32-crockford-checksum 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/base32/crockford.rb +6 -4
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 61c5a725b72dca942c6d42fb4604ad39a9f0e68c
4
- data.tar.gz: 8c8c017e3de34c23c637d9d80345cc24d699497f
3
+ metadata.gz: f0454e5e07505f92f7beec666f008e25d6a8e85e
4
+ data.tar.gz: f1b318370c7de922f9b157914eeb15cc0805988b
5
5
  SHA512:
6
- metadata.gz: 3cad2f783852a551f5e89a7e7052b0a38f1480c570380981ea5243288d59a566a299713b2c18f8dafb39858661b81790cb16365894c05e0955b47392f667a6e4
7
- data.tar.gz: bc28de71354b16a088d013aabcfc7378e839d7208f1872c5c0a42e2be2db204e74b84580c6d37a390ec95e74ea5640fc643829448032529d64d3e8f1fb3cb6e9
6
+ metadata.gz: c235578e85ff42866b9d6072645dde585bf22fef8b1d8a18d4e312970c08d2373ef37209454a1e8f3ece7a9d328218f120d8acde5d1b165e05cb82e062b57686
7
+ data.tar.gz: 5a4e1f832420d86ceaa189c961f3d0d969778f307cd1f5ebce886b61c3e5129494b4cdaa6217388dae06de1031f6f940572cb25088839f4e3689f3da742af82c
@@ -41,17 +41,19 @@ end
41
41
  #
42
42
  #
43
43
  class Base32::Crockford
44
- VERSION = "0.2.2"
44
+ VERSION = "0.2.3"
45
45
 
46
46
  ENCODE_CHARS =
47
47
  %w(0 1 2 3 4 5 6 7 8 9 A B C D E F G H J K M N P Q R S T V W X Y Z ?)
48
48
 
49
- CHECKSUM_MAP = { "*" => 32, "~" => 33, "$" => 34, "=" => 35, "U" => 36 }
50
-
51
49
  DECODE_MAP = ENCODE_CHARS.to_enum(:each_with_index).inject({}) do |h,(c,i)|
52
50
  h[c] = i; h
53
51
  end.merge({'I' => 1, 'L' => 1, 'O' => 0})
54
52
 
53
+ CHECKSUM_CHARS = %w(* ~ $ = U)
54
+
55
+ CHECKSUM_MAP = { "*" => 32, "~" => 33, "$" => 34, "=" => 35, "U" => 36 }
56
+
55
57
  # encodes an integer into a string
56
58
  #
57
59
  # when +checksum+ is given, a checksum is added at the end of the the string,
@@ -75,7 +77,7 @@ class Base32::Crockford
75
77
  ENCODE_CHARS[bits.reverse.to_i(2)]
76
78
  end.reverse.join
77
79
 
78
- str = str + ENCODE_CHARS[number % 37] if opts[:checksum]
80
+ str = str + (ENCODE_CHARS + CHECKSUM_CHARS)[number % 37] if opts[:checksum]
79
81
 
80
82
  str = str.rjust(opts[:length], '0') if opts[:length]
81
83
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: base32-crockford-checksum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Levin Alexander
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-13 00:00:00.000000000 Z
11
+ date: 2016-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake