base32 0.3.2 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +17 -0
- data/{README → README.md} +13 -14
- data/base32.gemspec +4 -6
- data/lib/base32.rb +10 -5
- data/lib/base32/version.rb +3 -0
- metadata +20 -29
- data/lib/version.rb +0 -3
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5e5d47bd83119651fb595fcf9fb64e9fe5ae77ec8f7638b7f44958176d8d9af1
|
4
|
+
data.tar.gz: bcb82ae555d025fa55e7f3f551607eb1273df459b15bf68d42bf6d005e9cd04b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d1413d5c64515ccd175348256975f71e99a63e07f64689139eeae3f02c7162673c23e6858761d1d4f1a9c18d6ec8730a71fd80dd5e935c58952878995b7274bc
|
7
|
+
data.tar.gz: 3d860ab09a8db3c0ea94ea2305481eb8a47a2795393249ec70d555181f747efdbc1f3977ed9072ea8cbf4a3c809ab122836b0c15375fc3b2828c5293f8d853f8
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 0.3.4
|
4
|
+
- PR #7: Updated README formatting (contributer: codehs)
|
5
|
+
- PR #8: Include license in gemspec (contributer: flavio)
|
6
|
+
- PR #9: Detect invalid characters when decoding (contributer: voondo)
|
7
|
+
- PR #10: Properly initialize character table (contributer: pwnall)
|
8
|
+
- PR #11: Move version.rb into lib/base32 (contributer: pravi)
|
9
|
+
- PR #12: Fix deprecation warnings (contributer: kenchan)
|
10
|
+
- PR #13: Fix build errors (contributor: kenchan)
|
11
|
+
|
12
|
+
## 0.3.2
|
13
|
+
|
14
|
+
- PR #5: Make padding optional for `random_base32` (contributer: lukesteensen)
|
15
|
+
|
16
|
+
## 0.3.1
|
17
|
+
|
18
|
+
- PR #4: Fix compatibility with older JRubies (contributor: localshred)
|
19
|
+
|
3
20
|
## 0.3.0
|
4
21
|
|
5
22
|
- Add `Base32::random_base32` function
|
data/{README → README.md}
RENAMED
@@ -1,50 +1,49 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
{<img src="https://travis-ci.org/stesla/base32.png" />}[https://travis-ci.org/stesla/base32]
|
4
|
-
{<img src="https://codeclimate.com/github/stesla/base32.png" />}[https://codeclimate.com/github/stesla/base32]
|
1
|
+
# base32
|
5
2
|
|
6
3
|
For Version: 0.1.3
|
7
4
|
|
8
5
|
This package contains base32, a Ruby extension for encoding and decoding
|
9
6
|
in base32 per RFC 3548.
|
10
7
|
|
11
|
-
|
8
|
+
## Download
|
12
9
|
|
13
10
|
The latest version of base32 can be found at
|
14
11
|
|
15
12
|
http://rubyforge.org/frs/?group_id=3938
|
16
13
|
|
17
|
-
|
14
|
+
## Installation
|
18
15
|
|
19
|
-
|
16
|
+
### Normal Installation
|
20
17
|
|
21
18
|
You can install base32 with the following command from the distribution
|
22
19
|
directory.
|
23
20
|
|
24
|
-
|
21
|
+
` rake install`
|
25
22
|
|
26
|
-
|
23
|
+
### Gem Installation
|
27
24
|
|
28
25
|
Download and install base32 with the following command.
|
29
26
|
|
30
|
-
|
27
|
+
` gem install --remote base32`
|
31
28
|
|
32
|
-
|
29
|
+
### Running the Test Suite
|
33
30
|
|
34
31
|
If you want to run the automated tests for base32, issue this command from the
|
35
32
|
distribution directory.
|
36
33
|
|
37
|
-
|
34
|
+
` rake test:all`
|
38
35
|
|
39
|
-
|
36
|
+
## References
|
40
37
|
|
41
38
|
* RFC 3548: http://www.faqs.org/rfcs/rfc3548.html
|
42
39
|
|
43
|
-
|
40
|
+
## Simple Example
|
44
41
|
|
42
|
+
```rb
|
45
43
|
require "base32"
|
46
44
|
|
47
45
|
encoded = Base32.encode("chunky bacon!") #==> "MNUHK3TLPEQGEYLDN5XCC==="
|
48
46
|
decoded = Base32.decode(encoded) #==> "chunky bacon!"
|
49
47
|
|
50
48
|
puts %Q{"#{decoded}" is "#{encoded}" in base32}
|
49
|
+
```
|
data/base32.gemspec
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
$:.
|
2
|
-
require 'version'
|
1
|
+
$:.unshift File.expand_path('../lib', __FILE__)
|
2
|
+
require 'base32/version'
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = 'base32'
|
@@ -7,16 +7,14 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.authors = ['Samuel Tesla']
|
8
8
|
s.email = 'samuel.tesla@gmail.com'
|
9
9
|
s.summary = 'Ruby extension for base32 encoding and decoding'
|
10
|
+
s.licenses = ['MIT']
|
10
11
|
|
11
12
|
s.files = `git ls-files`.split($/)
|
12
13
|
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
13
14
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
14
15
|
s.require_paths = ['lib']
|
15
16
|
|
16
|
-
s.
|
17
|
-
s.extra_rdoc_files = ['README']
|
18
|
-
|
19
|
-
s.post_install_message = File.read('UPGRADING') if File.exists?('UPGRADING')
|
17
|
+
s.post_install_message = File.read('UPGRADING') if File.exist?('UPGRADING')
|
20
18
|
|
21
19
|
s.add_development_dependency 'rake'
|
22
20
|
s.add_development_dependency 'minitest'
|
data/lib/base32.rb
CHANGED
@@ -3,6 +3,11 @@ require 'openssl'
|
|
3
3
|
# Module for encoding and decoding in Base32 per RFC 3548
|
4
4
|
module Base32
|
5
5
|
TABLE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'.freeze
|
6
|
+
@table = TABLE
|
7
|
+
|
8
|
+
class <<self
|
9
|
+
attr_reader :table
|
10
|
+
end
|
6
11
|
|
7
12
|
class Chunk
|
8
13
|
def initialize(bytes)
|
@@ -13,7 +18,11 @@ module Base32
|
|
13
18
|
bytes = @bytes.take_while {|c| c != 61} # strip padding
|
14
19
|
n = (bytes.length * 5.0 / 8.0).floor
|
15
20
|
p = bytes.length < 8 ? 5 - (n * 8) % 5 : 0
|
16
|
-
c = bytes.inject(0)
|
21
|
+
c = bytes.inject(0) do |m,o|
|
22
|
+
i = Base32.table.index(o.chr)
|
23
|
+
raise ArgumentError, "invalid character '#{o.chr}'" if i.nil?
|
24
|
+
(m << 5) + i
|
25
|
+
end >> p
|
17
26
|
(0..n-1).to_a.reverse.collect {|i| ((c >> i * 8) & 0xff).chr}
|
18
27
|
end
|
19
28
|
|
@@ -57,10 +66,6 @@ module Base32
|
|
57
66
|
@table = table
|
58
67
|
end
|
59
68
|
|
60
|
-
def self.table
|
61
|
-
@table || TABLE
|
62
|
-
end
|
63
|
-
|
64
69
|
def self.table_valid?(table)
|
65
70
|
table.bytes.to_a.size == 32 && table.bytes.to_a.uniq.size == 32
|
66
71
|
end
|
metadata
CHANGED
@@ -1,106 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: base32
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
5
|
-
prerelease:
|
4
|
+
version: 0.3.4
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Samuel Tesla
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2020-08-25 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rake
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: minitest
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: gem-release
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - ">="
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
description:
|
63
56
|
email: samuel.tesla@gmail.com
|
64
57
|
executables: []
|
65
58
|
extensions: []
|
66
|
-
extra_rdoc_files:
|
67
|
-
- README
|
59
|
+
extra_rdoc_files: []
|
68
60
|
files:
|
69
|
-
- .gitignore
|
70
|
-
- .travis.yml
|
61
|
+
- ".gitignore"
|
62
|
+
- ".travis.yml"
|
71
63
|
- CHANGELOG.md
|
72
64
|
- Gemfile
|
73
65
|
- LICENSE
|
74
|
-
- README
|
66
|
+
- README.md
|
75
67
|
- Rakefile
|
76
68
|
- base32.gemspec
|
77
69
|
- config/environment.rb
|
78
70
|
- lib/base32.rb
|
79
|
-
- lib/version.rb
|
71
|
+
- lib/base32/version.rb
|
80
72
|
- test/base32_test.rb
|
81
73
|
homepage:
|
82
|
-
licenses:
|
74
|
+
licenses:
|
75
|
+
- MIT
|
76
|
+
metadata: {}
|
83
77
|
post_install_message:
|
84
78
|
rdoc_options: []
|
85
79
|
require_paths:
|
86
80
|
- lib
|
87
81
|
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
-
none: false
|
89
82
|
requirements:
|
90
|
-
- -
|
83
|
+
- - ">="
|
91
84
|
- !ruby/object:Gem::Version
|
92
85
|
version: '0'
|
93
86
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
-
none: false
|
95
87
|
requirements:
|
96
|
-
- -
|
88
|
+
- - ">="
|
97
89
|
- !ruby/object:Gem::Version
|
98
90
|
version: '0'
|
99
91
|
requirements: []
|
100
|
-
|
101
|
-
rubygems_version: 1.8.23
|
92
|
+
rubygems_version: 3.1.2
|
102
93
|
signing_key:
|
103
|
-
specification_version:
|
94
|
+
specification_version: 4
|
104
95
|
summary: Ruby extension for base32 encoding and decoding
|
105
96
|
test_files:
|
106
97
|
- test/base32_test.rb
|
data/lib/version.rb
DELETED